After working through the TeX book and actually bothering to be more rigorous TeX-wise, I would like to add my own answer to complement the excellent answer above.
First, the meaning of any macro expanded once can be done using \meaning<your macro>
in the LaTeX document and compiling. Alternatively, the source code for latex2e or latex3 is available at the latex-project. For example, the newline macros are defined here or with comments (for LaTeX2e) here.
Second, the plain TeX \break
expands to either \linebreak
or \pagebreak
and gives a maximum negative demerit (-10000), ensuring that the TeX engine places a line break or new page at that point. This might mean that the hbox the line lives in is underfull, and so one should not use it on its own. Instead \hfil \break
is better in plain TeX, which gives infinite (a 'small' infinity) glue to fill out the rest of the line. But on its own \hfil \break
has a slight defect if the line is overfull - a null line will be introduced, as in
\hbox{aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
aa aa aa aa aa} \hfil\break aa aa aa
To remedy this, the documentation linked to above tells us that the newline definition was modified to include \nobreak \hfil \break
, to stop the overfull box automatically generating a line break. Finally, the prefix \unskip
is added to remove any blank spaces at the end of the line, which is probably useful. Thus we want \newline
to be the same as \unskip \nobreak \hfil \break
- which it essentially is. The complicated definitions as seen in the other answer are explained below and are essentially to simultaneously treat \\
and its variants.
Third, \par
is the same as leaving a blank line in plain TeX.
Now, I move onto unwrapping the complicated definitions of \newline
and \\
. The above answer is excellent. However, in the following I want to illustrate it in more concrete terms.
First, it is useful to note the following expansions (assuming plain LaTeX):
\newline --> \@normalcr\relax
\\ --> \@normalcr
Now, \@normalcr
comes in a starred and unstarred variety. Its expansions are illustrated in the following diagrams, where I use the shorthand \e = \reserved@e
and \f = \reserved@f
:
Hence, assuming we are not in vertical mode, in which case we will get a @nolnerr ("there is no line here to end") error, one has
\@normalcr --> \unskip \relax{\relax \relax} \nobreak\hfil\break
\@normalcr[1pt] --> \unskip \vadjust{\relax \vskip 1pt} \nobreak\hfil\break
\@normalcr* --> \unskip \vadjust{\nobreak \relax} \nobreak\hfil\break
\@normalcr*[1pt] --> \unskip \vadjust{\nobreak \vskip 1pt} \nobreak\hfil\break
It follows that \newline
does not have a starred version or argument with [] delimiters, so only the following expansions are possible:
\newline --> \unskip \relax{\relax \relax} \nobreak\hfil\break\relax
\\ --> \unskip \relax{\relax \relax} \nobreak\hfil\break
\\[1pt] --> \unskip \vadjust{\relax \vskip 1pt} \nobreak\hfil\break
\\* --> \unskip \vadjust{\nobreak \relax} \nobreak\hfil\break
\\*[1pt] --> \unskip \vadjust{\nobreak \vskip 1pt} \nobreak\hfil\break
In the above, \unskip
removes any existing spaces at the end of the line, \nobreak \hfil
adds glue to fill out the rest of the line without breaking, then \break
gives a maximum penalty (10000) to ensure a line break.
One should be a bit careful about the expansions of \\
and its cousins, because many environments redefine \\
as the answer above notes.
From the above, I conclude that a good intuition is that \newline
behaves more or less like \hfil \break
(adding infinite glue to the right and then breaking), and is also identical to the bare-bones version of \\
(the difference is a technicality - one has a final \relax
).
The other variations include either a \vadjust{\vskip x}
(unstarred version) or \vadjust{\nobreak \vskip x}
(starred version) just before the line break. I have a question with two good answers here explaining the point of these. The short story is that the unstarred case introduces some vertical space before the next line, which is allowed to be swallowed by a page break, whereas the starred version generally prevents a page break between the line and the vertical space (i.e. it will move the line to the next page). The latter is not quite true at the beginning of a paragraph - see the linked question immediately above.