On Fri, Dec 01, 2006 at 02:48:39PM +0100, Jean-Marc Lasgouttes wrote: > >>>>> "Enrico" == Enrico Forestieri <[EMAIL PROTECTED]> writes: > > Enrico> Now, when \csname is used to define a command for the first > Enrico> time, this command is made equivalent to \relax until it is > Enrico> redefined. > > Ahh, I did not know that \csname...\endcsname could define the macro > if it did not exist...
This is what the TeXbook says: When TeX expands \csname it reads to the matching \endcsname, expanding tokens as it goes; only character tokens should remain after this expansion has taken place. Then the `expansion' of the entire \csname...\endcsname text will be a single control sequence token, defined to be like \relax if its meaning is currently undefined. > Enrico> For example, one could define such a thing: > Enrico> \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} > Enrico> to do something like \ifundefined{foo}...\else...\fi (This is > Enrico> exercise 7.7 in the TeXbook). > > But in this case \ifundefined is non-const (in the c++ sense), isn't it? Yes, after that you will find that you have a \foo command equivalent to \relax. > Enrico> Moral is that you have to define \endXXX only if you have to > Enrico> actually do something when the environment XXX ends. > > OK. \begin{em}emphasized\end{em} and not emphasized. It works... -- Enrico