I'd like to set the control sequence \my_cs to the value of some LaTeX3 expression that expands to a control sequence, e.g. to the value of

\use:c {some_other_control_sequence}

In other words, \some_other_control_sequence is an existing control sequence that is set to some value, and I'd like to set \my_cs to this value, but without writing out the control sequence \some_other_control_sequence explicitly. How can I do so?

For instance, suppose \some_other_control_sequence is a global LaTeX3 variable set to the integer 42, and suppose I'm writing a LaTeX3 function, and the name of this variable, namely some_other_control_sequence is expected to be passed in as the parameter #1, but I don't know the name of this variable at the time of writing the function. How can I set \my_cs to \some_other_control_sequence's value, namely 42, inside the function that I'm writing?

  • If it is 'set to some value' presumably it's a variable, or is this a function? Also the \use:c implies the name is constructed on-the-fly: is that the case or it is known in advance? – Joseph Wright Oct 6 '17 at 8:38
  • @JosephWright: It is a variable. – Evan Aad Oct 6 '17 at 8:39
  • @JosephWright: It is constructed on-the-fly. – Evan Aad Oct 6 '17 at 8:44
  • 2
    Sounds (but I wouldn't bet on it) as if you are looking for \cs_set_eq:cc {my_cs}{#1}. – Ulrike Fischer Oct 6 '17 at 9:02

Each of the variable typs in expl3 has a series of set_eq functions for this task, for example

\tl_set_eq:NN \l_my_new_tl \l_my_old_tl
\seq_set_eq:Nc \l_my_new_seq { g_my_old_seq }
\dim_gset_eq:cc { g_my_new_dim } { l_my_old_dim }

Notice that both N- and c-type arguments may be used and that the scope should be correct for the variable being set.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.