2010-09-12 A strange LaTeX error when using brackets (en)

Some time ago my friend called me and asked about a weird error he got when using square brackets. He wanted to type something like

\begin{verse}
A line of a poem\\
[which] is followed by another one.
\end{verse}

Quite surprisingly, he got a “! Missing number, treated as zero” error message (and an “! Illegal unit of measure” right after that).

Well - not that surprisingly. The “newline” command (\\) takes an optional argument (additional vertical space to be put after the line), so that you can write \\[6pt] to get 6pt more of space between the line containing the command and the next one. What happened? LaTeX tried to treat which as a length, which was invalid; so it put a zero there. Next, a length unit should follow (which did not), so LaTeX put pt.

What should be done? There are a few possibilities, like saying \\[0pt], or \\{}. My personal favourite, however, is to say \\\relax - \relax is a “no-op”, that is, a TeX command doing nothing - but its role here is to be something different that the opening square bracket, so that LaTeX does not try to treat [which] as an optional argument.

CategoryTeX, KategoriaTeX, KategoriaLaTeX, KategoriaLaTeXPorady