[Tex/LaTex] the difference between \newline and \\


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?

Best Answer

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:

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

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.

Related Question