# How to add line break to caption without using caption package

I wish to add a line break to a caption, but I would wish to avoid adding of caption package. Is it possible?

\documentclass{article}
\usepackage[format=plain,
justification=raggedright,singlelinecheck=false]{caption}
\begin{document}
\begin{figure}
\caption{This is the caption\\ This is the second line}
\end{figure}
\end{document}

• Why don't you want to use caption package? – hpesoj626 Mar 9 '13 at 3:31
• @hpesoj626 it's related to this question:tex.stackexchange.com/questions/101424/… – william007 Mar 9 '13 at 3:37
• Unless you specifically need a linebreak I suggest you make two paragraphs by adding a blank line. – Backlin Sep 24 '18 at 15:31

\documentclass{article}
\begin{document}
\begin{figure}
\caption[caption]{This is the caption\\\hspace{\textwidth}This is the second line}
\end{figure}

\end{document}


The reason why \\ does not work originally is that the caption is small enough to fit on one line. The default caption setting first sets the caption in an mbox and if that is less than the line width that box is centred. Otherwise that box is discarded and the caption is re-set in a parbox. On the first setting \\ does nothing as it is always a no-op in such a box, on the second setting (if it is used) then \\ starts a new line. So all you have to do is make sure that the first setting is not used, as the space at the start of a line is discarded, it doesn't really matter how big the space is, so long as the total natural width of the whole caption is bigger than \textwidth.

• I think the \\ can be omitted? – Yiannis Lazarides Mar 9 '13 at 12:10
• @YiannisLazarides no see comment to Hendrick (it sort of works in this case but you get an overfull box) but in general you need \\  as the setting is not raggedright by default) – David Carlisle Mar 9 '13 at 12:15
• @David: Wow, great explanation, thank you very much! – Hendrik Vogt Mar 9 '13 at 20:07
• In an Overleaf document I was unable to include \\, but the hspace worked nicely. It used IEEEtran.cls (packages [utf8]inputenc, framed, booktabs, hyperref, wrapfig, tikz, todonotes, regexpatch, xcolor, listings). The error was: Argument of \Hy@tempa has an extra }. <inserted text> \par l.631 .... – drevicko Apr 7 '17 at 21:17
• Nice answer. I defined a new command like so \newcommand\nextline{\\*\hspace{\textwidth}} with the star version of \\* to prevent a new page. Reasonable? – PatrickT Sep 18 '18 at 13:39

The problem with using \\ in \caption{..} (a single mandatory argument) is that this defaults to \caption[..]{..} (optional + mandatory), and \\ is problematic in the optional argument. If you specify an alternative non-\\ optional argument, then it's okay, but \\ is made "useless" or has no effect. You could use a tabular to set the argument:

\documentclass{article}
\begin{document}
\begin{figure}
\caption[This is the caption; This is the second line]
{\tabular[t]{@{}l@{}}This is the caption \\ This is the second line\endtabular}
\end{figure}
\end{document}


Of course, if you don't need the optional argument (since you might not be using a \listoftables), just use an empty optional argument. Without more context of the requirement, I'm not sure how useful it might be.

Not sure why, but a \protect\linebreak works in the boxhandler package, but not in the \caption command.

\documentclass{article}
\usepackage{boxhandler}
\begin{document}

\bxfigure{Caption goes \protect\linebreak here}
{\fbox{Goodbye, very, very, very cruel world}}

\begin{figure}
\begin{center}
\fbox{Goodbye, very, very, very cruel world}
\caption{Caption goes \protect\linebreak here}
\end{center}
\end{figure}

\end{document}


One alternative is a minipage with \\ in the long caption. Note that in this way, the sort caption (between []) is not longer optional but as mandatory argument. If you want also a line break in the list of figures, simply use a \newline in the sort caption:

Edit: As Werner noted, the width of minipage must be less than \linewidth to avoid problems (now corrected in the MWE) or use varwidth package)

\documentclass{article}
\begin{document}
\listoffigures
\begin{figure}
\centering
\caption
[This is the caption \newline This is the second line]
{\begin{minipage}[t]{.8\linewidth}This is the caption \\This is the second line \end{minipage}}
\end{figure}
\end{document}

• This probably was accompanied by a bad box... – Werner Mar 9 '13 at 6:27
• @Werner, what do you mean by "bad box" is the "Overfull \hbox" warning? How dangerous is it really? – Fran Mar 9 '13 at 7:13
• Since you're setting the contents in a box, if the figure name + number + first line of caption > \textwidth, it will spill over the margin visually. While that may never happen, the box will necessarily push the caption to the left (always) because of its size. In this instance it would be better to use varwidth. – Werner Mar 9 '13 at 15:34
• As usual you're right. Funnily, I really did a first draft with varwidth, but then I thought that if he wanted a solution without caption package, he would not want a solution using another package and tested that original minipage worked also in the MWE. – Fran Mar 9 '13 at 18:52

Alternatively, you can use \protect\linebreak.

For a short caption text, it works the same as \\\hspace{\textwidth}. However, it can be a better solution, if your caption text is longer and without the line break would occupy more than one line and if you want it to be stretched to fill the line.

Example:

\caption{This is the caption\\ This is the second line}

\caption{This is the caption\protect\linebreak This is the second line}

\caption{This is the first line of a caption text that without the linebreak\\ would occupy more than one line and it goes and it goes}

\caption{This is the first line of a caption text that without the linebreak\protect\linebreak would occupy more than one line and it goes and it goes}

I would highly suggest using:

\protect\\


for new lines, as it is the only variant I tried, that did not mess with the formatting in e.g. the list of figures.

\documentclass{article}
\usepackage[format=plain,
justification=raggedright,singlelinecheck=false]{caption}
\begin{document}
\begin{figure}
\caption{This is the caption \protect\\ This is the second line}
\rule{3cm}{3cm}
\end{figure}


Example taken from here.

The accepted and most popular answer with:

\\\hspace{\textwidth}


does result in formatting issues!

• What formatting issues result? – dgoodmaniii May 23 at 14:28
• In my "list of figures" section, the first Letter after the \\\hspace{\textwidth} always ended up misplaced. Usually at the right side of the document. The rest of the word then continues in the next line. This may be due to the list of figures (or other sections) having a different textwdith... – gaussit May 24 at 11:34