What exactly do
\endcsname do? What are their job?
I have glanced at the Texbook and some other books, but none of them was clear enough to me.
Can anyone please give a simple example to clarify this issue?
Normally, control sequence names are made only of letters or of one non-letter character.
A letter is, more precisely, a character having category code 11 at the moment the control sequence name is read. So, any character can become part of a control sequence name, provided we change its catcode before the definition and each usage.
However, this is not the main purpose of
Another important use is in environments: when you say
When one says
It's possible to give many other interesting uses of this trick. But one should always keep in mind that TeX does complete expansion of what it finds in that context and that only characters must remain. So
is forbidden. But, after
will be legal and equivalent to saying
It's better to add something about category codes. An active character in
will give an error (Missing
Suppose you want to define a command
For reference, from the TeX Book (with slight formatting changes), Chapter 7: How TeX Reads What You Type (p 40):
I have used this indirectly by using the
This creates a "successive label
Actually, it is a perhaps strange joke that by the rules of LaTeX macros, you can actually write
(when run with
As an example: The xskak-Package loops through the notation of a chess game and stores a lot of informations of every move in commands. Its code contains a lot of definition of this type: