Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 1
    there is no need to "build" a macro. You can simply append e.g. with \tl_put_right:Nn Commented Aug 24, 2022 at 19:24
  • it might be worthy learning the hook system of the latest few releases of the LaTeX kernel. I've found myself replacing 5 or 6 uses of etoolbox's \pretocmd-and-friends with \AddToHook Commented Aug 25, 2022 at 2:40
  • So many assignments :( Commented Aug 25, 2022 at 7:17
  • 1
    I kind of covered this (tricks to handle unbalanced token list in TeX, by putting something that x-expands to the desired token list) in tex.stackexchange.com/a/638453/250119, but maybe also see other answers under there. But "appending" a \ does require manipulating the whole thing as a string and \scantokens the result, it may be a better idea to learn how tokens work in TeX and manipulate the input as a token list directly instead of a string. ■ Side note, \tl_put_right:Nn in a loop has quadratic time complexity, use \tl_build_put_right:Nn etc. for performance. Commented Aug 26, 2022 at 0:11
  • 1
    A bit odd many people don't see the usefulness of this, while it's used in e.g. expl3 source code e.g. in \__regex_replacement_put:n to allow "appending" e.g. unbalanced { or } to a "token list". They think other people don't want to write complex macros? Commented Aug 26, 2022 at 0:21