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.

Section 3.20 of the KOMA-script documentation ("scrguien.pdf", pp. 120-1) prescribes the syntax \setcapwidth[justification]{width} for the formatting of a caption. [c] is the option for centering.

Trying to produce the same output I get from the use of the caption package with options for justification and width, I'm surprised to see that the justification is quite different: KOMA-script produces a hanging caption that is justified, rather than centered in the strict sense.

My question: is there a way to produce the same output as in the caption example: centered and not hanging?

Examples follow, with an absurdly long caption to highlight the difference:

caption

\documentclass[12pt]{book}

\usepackage{graphicx}
\usepackage{lipsum}
\usepackage[justification=centering,width=.8\textwidth]{caption}

\begin{document}

\begin{figure}[htbp]
  \begin{center}
   \includegraphics{imageTest.png}
   \caption{\protect\lipsum[1]}
  \end{center}
\end{figure}

\end{document}

Output: enter image description here


KOMA-script

\documentclass[12pt]{scrbook}

\usepackage{graphicx}
\usepackage{lipsum}

\KOMAoption{captions}{belowfigure}
\setcapwidth[c]{.8\textwidth}

\begin{document}

\begin{figure}[htbp]
  \begin{center}
   \includegraphics{"imageTest.png"}
   \caption[short caption]{\lipsum[1]}
  \end{center}
\end{figure}

\end{document}

Output: enter image description here

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The horizontal centering of the text can be achieved by setting the indentation below the caption label to 0 pt and adding \centering to the font format of the caption:

\documentclass[12pt]{scrbook}

\usepackage{graphicx}
\usepackage{lipsum}

\setcapwidth[c]{.8\textwidth}
\setcapindent{0pt}
\addtokomafont{caption}{\centering}

\begin{document}

\begin{figure}[htbp]
  \begin{center}
   %\includegraphics{"imageTest.png"}
   \rule{2cm}{2cm}
   \caption[short caption]{\lipsum[1]}
  \end{center}
\end{figure}

\end{document}

The optional argument for \setcapwidth controls the alignment of the complete caption, not the justification of the caption text.

share|improve this answer

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.