130

As far as I know, \\ and \newline both insert a new line. But they do not have an identical expansion and tracing shows they do not execute the same commands, so what is their difference?

  • 4
    As far as I know, \newline is defined as the normal (i.e., without optional argument and non-starred) version of \\. – Gonzalo Medina Aug 30 '11 at 22:58
  • 1
    @Gonzalo: Yip, from latex.ltx1, \DeclareRobustCommand\newline{\@normalcr\relax} where expandafter\let\expandafter\@normalcr \csname\expandafter\@gobble\string\\ \endcsname. – Werner Aug 30 '11 at 23:28
  • 4
    Don't also forget the \linebreak command – Dr_Zaszuś Mar 27 '15 at 9:37
104
+200

From a usage point-of-view, there is a difference between \\ and \newline:

  • \\

    Tells LaTeX to start a new line. This command has a starred version and takes an optional parameter:

    • \\*: Similar to \\ but also tells LaTeX not to start a new page after the line by issuing a \nobreak.

    • \\[<len>]: This specifies the vertical space <len> to be inserted before the next line. Can also be negative.

    The above two can also be mixed. That is, using both a starred + optional argument combination \\*[<len>].

  • \newline

    Similar to \\.

From a technical point of view (in latex.ltx), these commands are defined as follows, justifying the similarity between \\ (unstarred and without optional argument) and \newline:

\DeclareRobustCommand\\{%
  \let \reserved@e \relax
  \let \reserved@f \relax
  \@ifstar{\let \reserved@e \vadjust \let \reserved@f \nobreak \@xnewline}%
  \@xnewline}
\expandafter\let\expandafter\@normalcr
  \csname\expandafter\@gobble\string\\ \endcsname
\DeclareRobustCommand\newline{\@normalcr\relax}

LaTeX also redefines \\ to mean other things depending on the environment(s) you use. For example, within an array or tabular environment, the commonly-used \\ has a slightly different meaning to when it is used in regular text.

  • 34
    Note that \\ will be redefined by some commands like \centering while \newline won't. For that reason using \newline with \centering will give undesired results. – Axel Sommerfeldt Aug 31 '11 at 7:15
  • 1
    Can you give an example of \\*[<len>] which skips 2 baselines? – Jeff Aug 2 '15 at 15:36
  • 24
    For someone who is new to Latex, your answer reads as: "From a usage POV, there is a difference between A and B: A does something, and B is similar to A. From a technical POV: [Don't understand a word]". Maybe you could add an example of different behavior in common text formatting situations? – Bananach Nov 1 '15 at 10:31
  • 4
    I don't understand the answer. "\\ tells ...., \newline Similar to \\". So is there a difference between the two or not? What's the difference? Is there an example where the two commands can give different results? – gigabytes Feb 14 '17 at 12:51
  • 1
    @gigabytes: As mentioned in comment, \centering would be one case where \\ and \newline would yield different results. See this paste and its accompanying output. – Werner Feb 14 '17 at 16:38
4

There is one important difference when used in the \title:

\documentclass{article}
\begin{document}
\title{First Line of a Long Title\newline Second Line of a Long Title}
\maketitle
\end{document}

produces

junk

Using

\documentclass{article}
\begin{document}
\title{First Line of a Long Title\\Second Line of a Long Title}
\maketitle
\end{document}

gives you, on the contrary,

what you wish

  • A bit more precise this is what Axel Sommerfeldt mentioned in his comment. title creates centered content and \centering etc. redefine \\ and now \newline. – TeXnician Aug 13 '18 at 14:37
  • @TeXnician Thx. Is there a typo in your comment? – user49915 Aug 13 '18 at 14:39
  • No, just markdown formatting which thinks that a backslash followed by a backtick should escape the backtick :) – TeXnician Aug 13 '18 at 14:41
  • @TeXnician Thx. "now \newline" -> "not \newline" ??? – user49915 Aug 13 '18 at 14:41
  • 1
    Oops, okay that one of course (my spellchecker didn't show it). But you got the point. It's basically Axel Sommerfeldt's comment on the other answer. – TeXnician Aug 13 '18 at 14:43

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.