4

How do I set the value of a variable such that its content is the value from another variable surrounded in curly braces?

For example, if \l_tmpa_tl is \alpha, how should I control expansion so that \l_tmpb_tl is {\alpha}?

What if I want \l_tmpb_tl to be {{\alpha}}?

Alan Xiang
  • 5,227

1 Answers1

5

Using \exp_not:V seems to do what you're looking for, although there may be a more elegant way.

Running this:

\nonstopmode
\ExplSyntaxOn

\tl_new:N \somemacro \tl_set:Nn \somemacro { some~content }

\tl_set:Nn \l_tmpa_tl { \somemacro } \tl_set:Nx \l_tmpb_tl {{{ \exp_not:V \l_tmpa_tl }}}

\ShowCommand \l_tmpa_tl \ShowCommand \l_tmpb_tl

\ExplSyntaxOff

\csname @@end\endcsname

gives this output:

> \l_tmpa_tl=macro:
->\somemacro .
<argument> \l_tmpa_tl

l.10 \ShowCommand \l_tmpa_tl

> \l_tmpb_tl=macro: ->{{\somemacro }}. <argument> \l_tmpb_tl

l.11 \ShowCommand \l_tmpb_tl

Max Chernoff
  • 4,667