Is there some facility in the LaTeX3 kernel to modify existing commands like etoolbox's \preto \appto and \patchcmd do?

1 Answer 1


No. The expl3 language is useful for both programming with existing LaTeX2e code and creating new code, and so there are some facilities which are '2e-facing'. However, patching existing commands is not an area we wish to encourage: it is much better if interfaces are provided for altering code flows, etc. Patching for LaTeX2e can as you note be achieved using etoolbox, whilst it should not be used for expl3 code at all (rather discussions should be undertaken to provide appropriate interfaces).

Note that \preto and appto are more-or-less the same at \tl_put_left:Nn and \tl_put_right:Nn, but there are no equivalents of \pretocmd/\apptocmd.

  • I tried to \tl_put_left:Nn \existingmacro { \new \directives } without success. Am I right to assume they only work on initialized token lists and not for arbitrary macros?
    – XZS
    Sep 10, 2015 at 12:46
  • @XZS As the name says, it's adding to the left of an existing token list (macro): the 'all vars must be declared' position is pretty clear in expl3.
    – Joseph Wright
    Sep 10, 2015 at 12:58
  • 1
    @JosephWright (off-topic question): it seems LaTeX3 parlance often refers to token lists which are not the same as the token list registers or variables from TeX. Am I wrong, and if not isn't it a bit confusing ?
    – user4686
    Sep 10, 2015 at 13:10
  • 2
    @jfbu I guess I should have put tl var in the above comment: we use tl var to refer to a TeX macro used as a storage bin. We don't use toks (token list registers) at all in expl3 (well, there are a few internal places but we don't expose them). The point thus is from an expl3 point of view there is no need to discuss toks at all.
    – Joseph Wright
    Sep 10, 2015 at 13:24
  • 1
    @jfbu The intention has always been that expl3 will be 'stand-alone', i.e. documented fully on its own terms rather than implicitly relying on (bits of) The TeXbook as a reference. We are not there yet but that is our direction.
    – Joseph Wright
    Sep 10, 2015 at 13:59

You must log in to answer this question.

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