Ross Moore ross at ics.mq.edu.au
Sat Aug 2 01:53:10 CEST 2003


On Tue, 29 Jul 2003, Gyori Sandor wrote:

> Dear TeXperts,
>
> I have found a strange problem in TeX, but I am not sure whether
>
> Originally, I wanted to put the following line in LaTeX:
> \paragraph{blabla $\notin$ blabla}
> and I got an error message:
> ! Illegal parameter number in definition of \reserved at a.
>                    \crcr

This kind of problem is very common, when you have macros in titles
or captions (and other things) that require fonts to be changed
to sizes or faces other than the normal text size and style.
Such commands are *fragile*, as is explained in any book about LaTeX.

The work-around is to use \protect, e.g. as
\paragraph{blabla $\protect\notin$ blabla}

This may not be the most elegant syntax, but it is a *necessary*
consequence of the flexibility of macro-like languages to have
constructions of this type to control when macros are expanded or not,
in various situations.

>
> This error message doesn't depend on documentclass or type of
> section (paragraph, section, subsection,...). The important thing
> is just \notin (which is a standard TeX command, see plain.tex
> for its definition, and gives a bit nicer output than \not\in)
> appears in the title of a paragraph.

Sure.
The problem is that you are expanding a macro which really
does not need to be expanded, in this context.
So just insert the \protect and all should be OK.

>
> Definition of \notin uses macro \c at ncel which uses through some
> calling of other macros (\ooalign, \oalign, \ialign) the TeX
> primitive function \halign. \halign doesn't "like" some situation
> or environment and the question is, why?

There is no need to go to this level of analysis.

>
> LaTeX's sectioning commands are complex, there are lots of macros
> calling each other. Simplifying this, I've expanded them,

Precisely; that's why \protect was devised.

> substituted them into each other and deleted the unnecessary
> commands. Finally, I've got a tiny, plain TeX example which
> also gives error message:

> I know that my example is unnatural and it could be simplified,

There is nothing *unnatural* about it at all.
The problem is well known; *every* responsible book about LaTeX
devotes some time to the discussion of *fragile* commands.

> The situation is the same in MikTeX & Windows and in teTeX & Unix.

Of course; LaTeX is designed to be consistent across platforms and
implementations. That is one of its great strengths.

> Do anybody has an idea? I am not on the list, so please send me

> Thanks.
>
> Best regards,
> Sandor Gyori

> PS. No, the problem is not because of the name of \reserved at a
> which is an often used (in various context) macro or variable
> in latex.ltx. You can see in the 2nd example that the error
> occurs with any name.

Generally, if you see @ characters in error/warning messages, then you
probably forgot to use \protect .

Hope this helps,

Ross Moore

> _______________________________________________
> TeX FAQ: http://faq.tug.org/