I have some code, and when I use
\\*, it causes some things to become unaligned, but when I use
\\, the alignment is correct.
What's the difference?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.Sign up to join this community
\\ command is one of the most overloaded commands of LaTeX, i.e., its actual definition depends on the place where it is used.
According to the the LaTeX manual by Leslie Lamport (which should be considered the source of truth here) its general definition is
\\produce an explicit line break (or indicate the end of a row etc)
\\*produce line break but do not break page here
Either variant can take an optional argument to add additional space after the line or row. This syntax is supported throughout core LaTeX even in places where it is technically impossible to have a pagebreak (for example inside a
tabular) you can still write
\\* without getting into a problem.
In core LaTeX the command is supported by environments like
verse, and commands like
\author and perhaps others. And of course it is supported in normal paragraph text.
But it does have different internal definitions in most of these places.
In standard LaTeX there can be spaces (or even a linebreak) between
* which can sometimes come as a big surprise.
For this reason
amsmath is redefining
\\ inside its math environments (like
align, etc.) to only recognize a
* if it is immediately followed.
Now given that
\\ is such a nice short command, other packages have adopted it as well, so you will find probably many more redefinitions of
\\ inside other packages. Ideally (assuming that it is used there also for indicating "line/row breaks") all these add-ons should follow the LaTeX example and provide the same syntax, i.e., supporting a
* form and one optional argument. However, there is no guarantee that this has been done always. If not, I would suggest to write to the package author and ask for supporting the standard LaTeX syntax fully. After all, if somebody writes a
superdupertabular but does this in a way that you can't place the body of a standard
tabular unchanged into it, then this is less helpful as it could be.
\\* starts a newline but avoids starting a new page, i.e. it is equivalent to
\\ immediately followed by
\nopagebreak. See What is the difference between \newline and \\? for more details.
(edited to correct
\nopagebreak, as suggested by comments below)