Exercise 7.6 of the texbook is as follows:

What tokens does '\expandafter\string\csname a\string\   b\endcsname' produce? (There are three spaces before the b.)

Here is my analysis to this problem and I'd like to know whether it's correct.

First of all, a\string\   b produces a token list: a(catcode 11), \(catcode 12), space(catcode 12) and b(catcode 11).

Then \csname and \endcsname make the token list into a control sequence \a\ b.

Finally, \string makes the control sequence into a list of character tokens: \(catcode 12), a(catcode 12), \(catcode 12), space(catcode 10), b(catcode 12)


1 Answer 1


The answer is in the back of the book

Your answer is right but mid stage analysis is wrong, \string\ makes a catcode 12 \ and catcode 10 space.

Also your implied timing is a bit misleading, The \csname is expanded first, before the inner \string, but then tokens are just collected up and made into a control sequence when \endcsame is reached.

You must log in to answer this question.

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