10

I recall seeing some comments that using a \\ to start a new line is a really bad idea outside of tabular type of environments.

What are the reasons for this?

  • If you look at latex.ltx you can see all the stuff that \par does apart from breaking the line. I guess this is what explains the differences with microtype and also the changes of font size? – cfr Oct 28 '14 at 3:42
  • 1
    Do you mean in comparison to \linebreak or \newline? Source2e suggests \newline is a simple implementation of \\ ; it also intimates there are some outstanding problems with \\ (though I thought more on 'edge' cases). I thought the main problem with using such a command outside tables is that it is indicative of a 'visual' and ad hoc approach to writing your LaTeX document, sort of like using hitting spacebar in Word 6 times to 'indent' a line. (More adept Word users might suggest using the Tab key instead.) – jon Oct 28 '14 at 5:26
  • 1
  • What's the reason to use \\? I mean, in what place do you need it? I've seen it misused as \\ \indent and also \\ \\ \\ \\ to add spaces between paragraphs. The answer, to me is easy, if you need to end a paragraph you leave a blank line; it's not if it's better or worse, it's the way to go. Unless on a special case where you should ask for that particular case. After rereading the title of the question When do you need a “newline indicator”? – Manuel Oct 28 '14 at 23:25
5

This is code I received when I was in charge of producing a conference proceedings volume (from my paper “Horrors in LaTeX: How to misuse LaTeX and make a copy editor unhappy”, TUGboat 26 (2005) n. 3; the paper contains other examples of bad uses of \\):

\item Let $S$ be the Diophantine monoid\\
$S = \{ x\in\N^3\mid 2x_1 + 5x_2 = 3x_3\}$.\\
As already seen, $S$ is generated by \\
$g_1 = (3, 0, 2),\ g_2 = (0, 3, 5),\
g_3 = (1, 2, 4),\ g_4 = (2, 1, 3)$.\\
One verifies easily that representation by $g_1$
and $g_2$ is unique and the Cale representations
of $g_3$ and $g_4$ by base $Q = \{g_1, g_2\}$ are\\
$3g_3 = g_1 + 2g_2\ \mbox{and}\ 3g_4 = 2g_1 + g_2$.\\
It follows that $k = 2,\ l = 4$ and $m = 3,\
m’_1 = m’_2 = 3,\ m’_3 = m’_4 = 1$.

enter image description here

There is no generally good reason for using \\ outside the environments where it makes sense. I have used \\ in some places, in order to solve some very specific problem, but it's not really important to mention which ones.

The authors of that gem were trying to keep together pieces that they deemed worthy of being on the same line and, for the first line break, to get a cheap display.

Of course this is a blatantly exaggerated misuse, but it shows two things:

  1. if users are made aware of \\, they'll immediately start misusing it;

  2. the influence of word processors on how people become used to see printed output is astonishingly strong.

The copy shown above is as unreadable as some Web pages where the flowing of text is kept in no care. Texts prepared with word processors are often as bad.

When normal justified text is concerned, there is no reason whatsoever for breaking a line midway. If a line break is desired at some point, the correct command to use is \linebreak that will still fill the line instead of ending it abruptly. Signalling the end of a paragraph with \\ is wrong, because no indent will be inserted in the next line. Typesetting without paragraph indentation is a very bad habit, in my opinion (but I'm following authorities like Tschichold). Some people use spaced paragraphs (horrible, but it's just my opinion), others no indentation and no spacing (unbearable).

Even for this last case, ending a paragraph with \\ is wrong. Rather, the parameter \parfillskip should receive a non zero natural width, say

\setlength{\parfillskip}{3em plus 1fil}

or, in Plain parlance

\parfillskip=3em plus 1fil

and still an empty line (or \par) should end a paragraph or the parameter wouldn't come into play. The setting would always leave at least 3em of blank space in the last line, giving readers a clue that a paragraph has ended.

Only in ragged right typesetting there are possible uses of \\, to force a break that TeX wouldn't take. However, such addition should be made during the final revision and certainly not when typing the manuscript. This doesn't invalidate my previous statement, that was about justified text. Moreover, ragged right typesetting is like being in a big flushleft environment and here \\ takes the place of \linebreak.

The objection that \\* prohibits a page break is sustained: the right command to use is \nopagebreak in the line above the point where we don't want a break.

Finally, (mis)using \\ for “leaving a blank line” is one of the worst errors: blank vertical space between paragraphs is very rarely necessary and, when needed, it is obtained with \medskip or \bigskip (the former is better, of course). A \\ by itself or \\ \\ invariably produce the Underfull \hbox message. “Fixing” it with ~\\ as somebody does deserves no comment.

  • (+1) Most helpful. What do you use if you want a line break within an \item and you specifically don't want the additional vertical separation which a new \item will (typically) create. That is, I often have itemisations in which I want a break (say, after something on the first line) but in which I don't want more than a normal line skip. I can use \par here or a blank line but it doesn't feel correct. – cfr Oct 29 '14 at 0:55
  • 1
    @cfr That might be a place for \\ (inside a specific environment, with a specific problem to solve), but I think that \par would still be better (with \parsep set to zero). – egreg Oct 29 '14 at 7:16
7

I don't know if any of these are the reasons but:

Line spacing

Line spacing behaves differently when you use \\ than when you use \par:

\documentclass{article}

\begin{document}
  This is some text and I want it to be fairly long so that it involves at least one line break.\\
  This is some text and I want it to be fairly long so that it involves at least one line break.

  \tiny This is some text and I want it to be fairly long so that it involves at least one line break.\\
  \normalsize This is some text and I want it to be fairly long so that it involves at least one line break.\\
  \Huge This is some text and I want it to be fairly long so that it involves at least one line break.\\
  \tiny This is some text and I want it to be fairly long so that it involves at least one line break.

  \normalsize This is some text and I want it to be fairly long so that it involves at least one line break.

  \Huge This is some text and I want it to be fairly long so that it involves at least one line break.

  \tiny This is some text and I want it to be fairly long so that it involves at least one line break.
\end{document}

weird spacings

Line breaks & Hanging punctuation

If you use microtype, you will get hanging punctuation, if appropriate, at the end of a paragraph but not if you end the paragraph with \\ (and the line breaks are different in this case):

hanging punctuation... or not

\documentclass[a5paper]{article}
\usepackage[showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\begin{document}

  This is some text and I want it to be fairly long so that it involves at least one line break.
  This is some text and I want it to be fairly long so that it involves at least one line break.
  This is some text and I want it to be fairly long so that it involves at least one line break.\\

  This is some text and I want it to be fairly long so that it involves at least one line break.
  This is some text and I want it to be fairly long so that it involves at least one line break.
  This is some text and I want it to be fairly long so that it involves at least one line break.

\end{document}
4

When you use \\ then you force LaTeX to break the lines so there would be underfull and overfull boxes (bad boxes) in a lot of cases. There may be other reasons too that I haven't heard of yet, but if you consistently use \\ then you are going to see a lot of bad boxes!

2

It is only an example, showing, how bad it can be.

\documentclass{article}

\begin{document}

\\

\end{document}

stops with an error.

  • 2
    Yeah, but the output is the same if you remove the `\`. :-) – Peter Grill Oct 28 '14 at 2:58

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.