7

I am trying to understand whether there is a proper expl3 way to achieve the same result as the latex2e \protected@edef, that is expanding a token list while respecting the \protect mechanism of latex2e.

Using expl3 functions with an "x" type argument (e.g. \tl_gset:Nx) seems to expand everything ignoring the latex2e protection mechanism.

I seem to be able to achieve the desired goal by manually replicating the mechanisms applied by \protected@edef, that is by doing a \tl_set:Nn \protect { \noexpand\protect\noexpand } right before the "x" expansion (e.g., before the \tl_gset:Nx), but I wonder if this is the preferred method or if there are more elegant alternatives.

1 Answer 1

7

There is no equivalent of \protected@edef in expl3 as 'native' expl3 material is either fully expandable or engine-protected. As such, if you do need to take mixed LaTeX2e input and use it in expl3, you'll need to stick to the LaTeX2e mechanism

\protected@edef \l_tmpa_tl { <stuff> }
1
  • 2
    While this is correct as far as pure expl3 code is concerned, the fact that we see more and more packages written in expl3 but intended to work seamlessly in 2e context means that we have to provide interfaces to certain 2e data structures and conventions to make this possible. the \protect mechanism is a good example because it should be possible for expl3 code to receive user data from a document and manipulate it with ease and in a cleaner way than currently possible. Commented Dec 26, 2018 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .