4

I tried to find a topic here on this (possible problem) but I didn't.

I reported it at TeXstudio SF but Tim Hoffmann pointed me that it is not a problem of editor. After tested with nano and pdflatex I'm posting here.

The minimal code produces errors. OK, we can solve it using \\{}.

But is this a problem with TeXlive 2014 or there are some good reasons to have that behavior.

\documentclass{report}
\begin{document}
test\\ [foo]

test\linebreak [foo]

test\newline [foo]
\end{document}

! Missing number, treated as zero. f l.3 test\ [foo]

6

Both \\ and \linebreak take an optional argument, and so you need to end the expansion with \relax, so that the bracket is taken as text, and not as an optional argument. The optional argument for \\, if used, is expected to be a length dimension indicating the additional vertical space to provide. And so [foo] does not qualify, thus generating an error.

For \linebreak, the optional argument is a number between 0 and 4. According to Lamport, "a larger value of [num] more strongly encourages or discourages the line break." The default is equivalent to 4. Thus, [foo] likewise breaks the expansion of \linebreak.

\newline, on the other hand, does not take an optional argument, and so [foo] following it works fine.

\documentclass{report}
\begin{document}
test\\\relax [foo]

test\linebreak\relax [foo]

test\newline [foo]
\end{document}

enter image description here

For example, test\\[12pt][foo]will add a larger gap after test and before [foo]:

\documentclass{report}
\begin{document}
test\\[12pt][foo]

test\linebreak\relax [foo]

test\newline [foo]
\end{document}

enter image description here

  • Ow, how I didn't realize that! Usually I use \\[xx] inside arrays but I did never think it as a possible optional argument for `\` when using in text mode. Thanks. – Sigur Jun 30 '14 at 20:59
  • @Sigur It was the use in arrays that clued me in to the nature of your problem. \linebreak on the other hand, I had to do additional research, but figured it was of a similar nature. – Steven B. Segletes Jun 30 '14 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.