I decided to test my understanding of expansion and embed \g@addto@macro within another three macros.


From my understanding, the output in the log for my example below should be:

  ==> item1item2\item \undefinedmacroA item5\undefinedmacroB

But in reality, it is:

  ==> item1item2\item \undefinedmacroA \undefinedmacroB






\appendmacro{\unexpanded{\item}} % Demonstrate that \unexpanded must be called by the sender
\typeout{ ==> \macrolist}
  • unrelated probably but you are missising % from ends of lines again Jun 16, 2016 at 14:26
  • 2
    \activatelayerone takes an argument ...
    – Joseph Wright
    Jun 16, 2016 at 14:29
  • @JosephWright DOH! Right when I think I am getting it, I make a rookie mistake like that. Jun 16, 2016 at 14:30

1 Answer 1


Apart from defining \layertwo to be append and add a spurious space because of the missing %, this acts as \@gobble to discard the next token as #1 is not used. Here the next token is \layertwo so that is discarded and {item5} is just typeset at that point.

You must log in to answer this question.

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