What exactly do \csname and \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. With However, this is not the main purpose of
so that Inside Another important use is in environments: when you say Other uses: When one says
and keep 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 Final noteIt's better to add something about category codes. An active character in
will give an error (Missing |
|||||
|
|
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
thereby expanding |
|||
|
|
|
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:
where |
|||
|
|
|
Suppose you want to define a command |
|||||||
|
|
Short answer: Actually, it is a perhaps strange joke that by the rules of LaTeX macros, you can actually write
(when run with |
||||
|
|