# When doesn't \\ start a new line in \caption?

Using the command in Why does parameter double when used in caption?, it works in most cases, but in a few cases (like 1 out of 20) \\ does not start a new line.

For example using

\begin{table}
\centering%
\begin{tabular}{llllll}
\hline
\textbf{Bezeichnung} & \textbf{x} & \textbf{y} & \textbf{z} &
$\mathbf{u'_N}$ & $\mathbf{v'_N}$ \\
\hline
... & ... & ... & ... & ... & ...
%...
\hline
\end{tabular}
\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{\Lt{Weisspunkte}}Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{\cite[S.~279]{poynton_digital_2012}\index{Illuminant}}}
\end{table}


in a table does not start a new line before Quelle, like this (see yellow line; rest of page pixelated to emphasize the important parts and to improve image compression):

Or shown in detail:

Note that the same command inserts a line-break before "Bildquelle:" in the figure above the table. I could not find a reference to a similar problem; could it be that LaTeX tried to avoid the line-break if vertical space on the page is tight?

For those who failed to find the \\, here it is (answer from the reference):

\newcommand{\FS}[2][Bildquelle]{%
\protect\ifthenelse{\equal{#1}{}}%
{\protect\\{\protect\scriptsize{}#2}}
{\protect\\{\protect\scriptsize{}#1: #2}}}


Forcing table 6.1 on a new page did not change the behavior. Making the caption text a bit longer or shorter also did not change the behavior. However when I changed the caption to

\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{\Lt{Weisspunkte}}Lorem ipsum Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{\cite[S.~279]{poynton_digital_2012}\index{Illuminant}}}


then the table went to the next page, and the line break was inserted:

MWE

Finally I managed to create a MWE (pdflatex, actually it was easier than expected):

\documentclass[a4paper,twoside]{report}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
\usepackage{makeidx}
\usepackage{showidx}
\newcommand{\FS}[2][Bildquelle]{%
\protect\ifthenelse{\equal{#1}{}}{%
\protect\\*{\protect\scriptsize{}#2}}{%
\protect\\*{\protect\scriptsize{}#1: #2}}}
\begin{document}
%
\begin{table}
\centering%
\begin{tabular}{llllll}
\hline
\textbf{Bezeichnung} & \textbf{x} & \textbf{y} & \textbf{z} &
$\mathbf{u'_N}$ & $\mathbf{v'_N}$ \\
\hline
A & B & C & D & E & F \\
A & B & C & D & E & F \\
A & B & C & D & E & F \\
A & B & C & D & E & F \\
\hline
\end{tabular}
\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{Weisspunkte}Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{[Poy12, S.~279]\index{Illuminant}}}
\end{table}
%
\begin{table}
\centering%
\begin{tabular}{llllll}
\hline
\textbf{Bezeichnung} & \textbf{x} & \textbf{y} & \textbf{z} &
$\mathbf{u'_N}$ & $\mathbf{v'_N}$ \\
\hline
A & B & C & D & E & F \\
\hline
\end{tabular}
\caption[Koordinaten ausgewählter Weißpunkte]%
{\label{Weisspunkte2}Koordinaten ausgewählter Weißpunkte%
\FS[Quelle]{[Poy12, S.~279]\index{Illuminant}}}
\end{table}
\end{document}


Looks like:

\usepackage[font=small,labelfont={sf,bf},position=bottom,singlelinecheck=false]%
{caption}


the result for the MWE looks like this, which is OK for me.

• There is no \\ in your example, so how shall we guess why it doesn't work as expected? Please provide a minimal working example (MWE). – Tiuri Nov 30 '19 at 22:18
• @Tiuri See the reference right at the start. A MWE will probably take me hours, specifically as it's likely the MWE will not show the problem. – U. Windl Nov 30 '19 at 22:22
• Sorry, I cannot reproduce your problem. I gathered the snippets from this question and the one you link to above, and I get a line break. So, the problem must be somewhere else in your code. For example in the definition for \Lt which I could not find. – Jasper Habicht Nov 30 '19 at 22:34
• If I replace \Lt{X} with X, it doesn't change the effect (which was expected, because \Lt stands for "label table", and effectively it just adds a prefix to the label given: \newcommand{\Lt}[1]{tab:#1}). – U. Windl Nov 30 '19 at 22:57
• Then we're not going to be able to reproduce your problem or solve it. But since you have an example that exhibits the problem, you can trim it down to a MWE. Move the relevant definitions into the example, and remove the extraneous text. If vertical spacing is a factor, use \parbox to make a box of the correct height. – Teepeemm Nov 30 '19 at 23:30

You can simplify the example:

\documentclass[a4paper,twoside]{report}

\begin{document}
\begin{table}
\caption[]{aaaaaaaaaaa aaaaaa
ccccccccccccccc bbbbbbbbbbbbbbb \\
dddddddddddddd}
\end{table}
%
\begin{table}

\caption[]{aaaaa\\bbb}
\end{table}
\end{document}


Most classes set captions in two styles, first essentially in an \mbox on a single line that is centred if it fits in the text box (and \\ does not do anything in an mbox). If that box is too wide to fit on a line it is discarded, and the caption i re-set in a \parbox, If the second format is used \\ will work.

The caption package has an option to skip the one-line test, if that is what you want here.

• I don't quite see the difference: Do I have to start a paragraph before \caption? Reviewing my document I found that most captions are rather long (longer than one line), so they "worked". As it seems my initial suspect was right: If it all fits in one line, it will be forced into one line, regardless of any \. Right? – U. Windl Nov 30 '19 at 23:59
• @U.Windl as I say if \mbox{short\\ caption} will fit on a line, it is used, and \\  does nothing in a mbox. It is normally best to avoid any use of forced linebreaks, but if you want to do this you can as i say use the caption package and disable the one-line setting. – David Carlisle Dec 1 '19 at 0:39
• the difference in my examples is simply that aaaaabbb fits on a line – David Carlisle Dec 1 '19 at 0:39