# What does \\* do?

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?

-
`\\*` often is used to introduce a linebreak, but preventing a page break; however, some environments redefine it, so you have to be more specific about the scenario in which you are using this command. –  Gonzalo Medina May 12 '12 at 3:55

The `\\` 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 `array`, `tabular`, `tabbing`, `eqnarray`, `center`, `flushleft`, `flushright`, `verse`, and commands like `\shortstack`, `\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 `\\` and `*` 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.

-
But isn't `\` expanded into something by tex? and when you add the `*` it gets attached to the end of that expansion which changes it's meaning slightly? –  Uiy May 12 '12 at 23:18
@Uliy you are mixing up concepts This is kind of true for environments where the * is added to the name that is constructed, but in the case of `\\ ` what happens is that the command explicitly scans for a following * and then for an `[` indicating an optional argument. In the process it jumps over spaces which is why you can write `\\ * [1cm]` and it will still be accepted. Having said that this is for the implementations done by LaTeX core ... as explained this may not be true for third-party packages. –  Frank Mittelbach May 13 '12 at 7:40
@Uliy from your questions in this forum, I suggest that you pick up either the TeXbook or TeX by Topic (the latter is freely available on the net) to get a thorough understanding of the basic concepts used in the LaTeX code. Only then something like the LaTeX source (i.e., source2e.pdf) can be successfully understood (if ever, some parts I guess none of use understand any more :-) –  Frank Mittelbach May 13 '12 at 7:44

`\\*` 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 `\nobreak` by `\nopagebreak`, as suggested by comments below)

-
`\\*` is not equivalent to `\\\nobreak`. `\nobreak` in that position would be in horizontal mode so would prevent a line break not a page break. –  David Carlisle May 12 '12 at 13:35
@David Ah, I agree I shouldn't have used the word "equivalent" as TeX experts are roaming these forums. But for someone who's not interested in the internals, I think the concept is clear; I'll gladly leave it up to you to explain `\@ifstar{\let \reserved@e \vadjust \let \reserved@f \nobreak \@xnewline}` (the exact `\\*` code from `latex.ltx`) if @Uiy is interested :) –  Xavier May 12 '12 at 23:57
point is it conceptually `\` followed by `\nopagebreak` (not true either but closer) and not followed by `\nobreak` as the latter is preventing a line break in horizonal mode. So it is not about the internals –  Frank Mittelbach May 13 '12 at 7:35
@Frank Oh sorry, I didn't got the comment in that sense. Fully agree and edited the answer to reflect this. –  Xavier May 15 '12 at 23:39

`\\` signals the end of the line (in text) as well as the end of a row (in environments like `tabular`, `align`, etc.).

Never seen or used a `\\*`.

-
I picked up `\\*` somewhere as it solved some problem and used it to solve some other problem then used it again and it caused problems ;) the `*`, I think gets stuck after \hfill or something so you end up with \hfill* –  Uiy May 12 '12 at 3:26