Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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]

share|improve this question
1  
There are several of these questions, but with more specific contexts than yours: tex.stackexchange.com/questions/95236/… tex.stackexchange.com/questions/34466/error-with-table tex.stackexchange.com/questions/144694/not-working?lq=1 (not an exhaustive list). Voted, for generality. :-) –  Paul Gessler Jun 30 at 20:34
    
@PaulGessler, I know about the problem inside arrays and tables. But since my problem is with a simple line, I decided to ask. Thanks. –  Sigur Jun 30 at 20:56

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
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 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 at 21:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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