Take the 2-minute tour ×  I thought I had understood the
principle of expansion ... but apparently not!    I thought that
the 2 \expandafter would store \detokenize and {} resp. and then
expand \a into AAA and \b into BBB. Therefore after one round of
expansion, we would have:   and thus the output should be simply
"AAABBB". But it is not the case. Where is my mistake?
share|improve this question Question titles must summaries the
question. Please avoid titles which would fit 1000 largely
different questions. –  Martin Scharrer Jun 9 '12 at 8:58
\expandafter jumps over one token, expands once the following
one (if it's expandable, otherwise nothing happens) and
vanishes. –  egreg Jun 9 '12 at 9:20 You might be looking for
\expandnext from etextools, which in your case could be used as
\expandnext\detokenize\a\b. –  dgs Jun 9 '12 at 10:41 add
comment  1 Answer  up vote 18 down vote accepted  \expandafter
stores exactly one token. So the expansion order is
\expandafter-\expandafter-\a.  After this everything i