From Wikibooks, open books for an open world
< TeX
Jump to navigation Jump to search

Synopsis[edit | edit source]


Description[edit | edit source]

Donald Knuth describes this as telling TeX to "do nothing." This seems like a pointless control sequence at first thought. However, some control sequences act on tokens that follow it, and \relax tells TeX to stop accepting new tokens for this control sequence. This is sometimes necessary to resolve otherwise ambiguous expressions.

Examples[edit | edit source]

The following piece of code looks just fine, but...

 Number & Text \\
 [a] & lorem ipsum \\
 [b] & lorem ipsum \\

... TeX throws an Error "! Missing number, treated as zero. <to be read again> a". TeX just ignores the end-of-line and reads the tokens "\\[a]" as \\[length]. To stop TeX reading into such things just tell it to \relax

 Number & Text \\ \relax
 [a] & lorem ipsum \\ \relax
 [b] & lorem ipsum \\

so TeX (and you) keep it cool.

Exercises[edit | edit source]