Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using the captions package, linebreaks can be incorporated into figure-captions easily:

\documentclass[12pt]{book}

\usepackage{graphicx}
\usepackage{caption}

\begin{document}
\begin{figure}[htbp]
  \begin{center}
   \includegraphics{sampleImage.png}
   \caption{First line of caption\\second line of caption\\third line of caption\\fourth line of caption}
  \end{center}
\end{figure}

\end{document}

producing enter image description here, with the line-breaks correctly observed.

Attempting something comparable with KOMA-script:

\documentclass[12pt]{scrbook}

\usepackage{graphicx}
\KOMAoption{captions}{belowfigure}

\begin{document}

\begin{figure}[htbp]
  \begin{center}
   \includegraphics{"sampleImage.png"}
   \caption{First line of caption\\second line of caption\\third line of caption\\fourth line of caption}
  \end{center}
\end{figure}

\end{document}

generates an error: Argument of \@caption has an extra }.

Is there another way to get line-breaks in a figure caption using KOMA-script?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

The reason is, that by default KOMA-Script captions are put into horizontal boxes, to measure if they are longer than one line or not. That's why line breaks by \\ or \newline don't have effect. You can disable this default behavior, for example, by using the KOMA-Script option for captions nooneline, so "one-line" captions are treated like multi-line captions.

Added in your example:

\KOMAoption{captions}{belowfigure,nooneline}

Then, you can get line breaks by \\ if you insert \protect before:

\caption{First line of caption\protect\\second line of caption}

However, it's not necessary if you specify an optional argument. It may be recommendable for such long captions, which might not be the optimum for the list of figures. So, this works too:

\caption[short caption]{First line of caption\\second line of caption}
share|improve this answer
    
Thank you. The use of the optional argument is especially useful. –  brannerchinese Aug 6 '12 at 20:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.