Questions tagged [expansion]
{expansion} is about expanding tokens, including the manipulation of expansion order and the suppressing of expansion.
1,201 questions
12 votes
1 answer
214 views
Why do expl3 setting commands use \edef?
Looking at the definition of \tl_set:Nn (for example, with latexdef \tl_set:Nn), we find \tl_set:Nn: \protected\long macro:#1#2->\__kernel_tl_set:Nx #1{\__kernel_exp_not:w {#2}} where \...
4 votes
2 answers
165 views
expl3: l3file: \iow_now:Ne... doesn't expand tokens before writing to the stream?
MWE: \documentclass{article} \begin{document} \ExplSyntaxOn \iow_new:N \g__test_iow \iow_open:Nn \g__test_iow { test.pl } \iow_now:Ne \g__test_iow { \# } \iow_close:N \g__test_iow \ExplSyntaxOff \end{...
4 votes
2 answers
142 views
Passing a macro as the argument to an arbitrary arg-spec
MWE: \documentclass{article} \usepackage{mathtools} \begin{document} \ExplSyntaxOn \tl_new:N \g__mymodule_env_name_tl \tl_new:N \g__mymodule_env_args_tl % Defaults \tl_set:Nn \g__mymodule_env_name_tl {...
9 votes
4 answers
418 views
Using macros to define optional arguments for environments
I am trying to use a macro to define the optional arguments to a tcbraster environment. Here is a simple example: \documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{raster} \def\myoptions{...
2 votes
1 answer
110 views
ConTeXt: Group several key-value pairs into one
I often find myself repeating the following at the start of my tables: \setupTABLE[<X>][<Y>][background=color, backgroundcolor=mycolor1, foregroundcolor=mycolor2] with only X or Y ...
3 votes
2 answers
167 views
Prevent multiple evaluations of commands in table environments (tabularx, tabulary, tblr)
I often need to hide answers using \phantom, and store them in an expl3 sequence via a custom command \addanswer, for later use. Each call to \addanswer is intended to store its argument only once. ...
8 votes
3 answers
296 views
Why is there no expansion of a local let despite using xdef here?
In this example: { \let\oldpar=\par \xdef\par{NEXT UP!\oldpar} } Par 1 Par 2 Par 3 \bye TeX complains that oldpar is not defined. I do not understand why it tries to look for a definition ...
10 votes
1 answer
233 views
Why does the definition of \newif use a \edef with \noexpand instead of a \def in plain \TeX?
I have been experimenting with the \newif construction in plain \TeX. To keep my experiments from clashing with plain \TeX, I changed the definition slightly to \outer\def\znewif#1{\count255=\...
5 votes
0 answers
71 views
Is there a better way to handle property references (ltproperties), some of which should be replicated in memoized code?
This is a semi-followup to How to debug/correct missing number error in plug during memoization?. Aim: handle properties (ltproperty) in memoized code (memoize). Specifically: A problem arises ...
4 votes
2 answers
187 views
Missing \endcsname inside of \edef
I know now that the code I am including here is the wrong way to save the output of a macro because expansion comes before function evaluation (so now I am doing something completely different), but I ...
3 votes
3 answers
250 views
How to force macro expansion in pdf metadata?
Background A custom document date and ID should be set in the pdf metadata of a presentation made with beamer. Consider the following MWE for scrreprt: % !TeX program = lualatex \documentclass{...
3 votes
1 answer
163 views
ConTeXt: unexpected behavior of redefined active ~ character
I got very surprised by the fact that seemingly when I use \def on active ~ it retains a protected status. Is that the expected thing? \ifdefined\starttext\else\let\starttext\empty\let\stoptext\end\...
4 votes
2 answers
151 views
Command to give a dimension expression with an optional argument
My aim is to create a command that issues a dimension for box height control. In the example below, I've tried to get it work with an optional argument but I don't get why it throws an error regarding ...
1 vote
1 answer
69 views
expansion question in `\tkzDrawSegments` with `tkz-euclide`?
I have the following code: \documentclass{article} \usepackage{tkz-euclide} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture} \matrix (m) [% matrix of math nodes, ] {% ...
5 votes
1 answer
77 views
Understanding \exp_last_unbraced:
I don't really understand how \exp_last_unbraced: works and what the documentation means by: "with the last argument not surrounded by the usual braces." How does it differ from the regular \...