Start of line goes awry

This answer concerns two sorts of problems: errors of the form

! Missing number, treated as zero.
<to be read again> 
                   g
<*> [grump]
and those where a single asterisk at the start of a line mysteriously fails to appear in the output.

Both problems arise because \\ takes optional arguments. The command \\* means "break the line here, and inhibit page break following the line break"; the command \\[<dimen>] means "break the line here and add <dimen> extra vertical space afterwards".

So why does \\ get confused by these things at the start of a line? It's looking for the first non-blank thing, and in the test it uses ignores the end of the line in your input text.

The solution is to enclose the stuff at the start of the new line in braces:

{\ttfamily
  /* C-language comment\\
  {[grump]} I don't like this format\\
  {*}/
}
(The above text derives from an actual post to comp.text.tex; this particular bit of typesetting could plainly also be done using the verbatim environment.)

The problem also appears in maths mode, in arrays and so on. In this case, large-scale bracketing of things is not a good idea; the TeX primitive \relax (which does nothing except to block searches of this nature) may be used. From another comp.text.tex example:

\begin{eqnarry}
  [a] &=& b \\
  \relax[a] &=& b
\end{eqnarry}
which is a usage this FAQ would not recommend, anyway: refer to the reason not to use eqnarray.

Note that the amsmath package modifies the behaviour of \\ in maths. With amsmath, the eqnarray example doesn't need any special measures.

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=newlineargs