# Why doesn’t LaTeX center captions by default?

As you certainly know LaTeX does not center figure captions by default. The first line is centered in most cases, but the following lines behave like regular text. Centering all the lines can be easily achieved with the caption package, but it’s not the default behavior. I’ve always wondered about this.

In general, using LaTeX with all default options and parameters (and a basic class such as report or book) ensures a document that is at least typographically correct and rather well designed. Arguably, you can always improve plenty of things, but the default is really OK (I would say) and can be used even with little typographical knowledge. Except for this caption centering thing (which is arguably the most shocking feature of a LaTeX document typeset with default settings). It just looks so wrong.

Why was this choice made by the LaTeX developers? Is it really bad practice to center captions, and is the LaTeX behavior ‘how it sould be’? Or is it just a bug or an involuntary side effect?

• I think this question is off-topic. You nicht have asked why the chapter title has the default size or why the main developer has a blue car. – Johannes_B Jan 5 '18 at 7:09
• LaTeX does not center the first line. LaTeX centers the caption paragraph if it fits on a single line. It is a very beautiful feature. – Paul Gaborit Jan 5 '18 at 7:17
• I would like to add this as a answer but that doesn't seem to be allowed. It was a design choice by Lamport. To center multiline captions without using additional packages: \caption{\protect\centering Multiline text} – Peter Wilson Jan 5 '18 at 18:49
• As a revision to my comment I should written it as ...Lamport the creator of LaTeX but other design decisions could have been made, as for example your preference. Robert Bringhurst's captioning style (in The Elements of Typographic Style) follows the default LaTeX style (except where he uses side captions) and few are willing to disagree with Bringhurst. To center multiline ... – Peter Wilson Jan 6 '18 at 18:47
• I have voted to reopen this question, because I do not agree with its closure as “primarily opinion-based”. That closure reason is for questions that invite opinions in their answers. This one is not such a question (at least, no one ought to post their own opinions as an answer). There exists a well-defined answer, e.g. Leslie Lamport or whichever person of the LaTeX development team made this decision can answer this question (and most of them are still alive). The fact that many typical users of this site cannot answer this question is not a reason to call it “primarily opinion based”. – ShreevatsaR Jan 8 '18 at 6:19

The standard LaTeX classes will centre the caption if it is shorter than the text width. Here is the relevant code from article.cls (or classes.dtx respectively)

\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}


Why this is the case I can't tell you.

It was a design choice by Leslie Lamport, the creator of LaTeX, but other decisions could have been made, as for example your preference. Robert Bringhurst in his The Elements of Typographic Style follows the default LaTeX style, except when he uses sidecaptions, and few would care to disagree with Bringhurst.

To center multiline captions without using any packages:

\caption{\protect\centering Your multiline text}


It's difficult to understand this question. The report and book class do center captions; if the caption length is less than \hsize, the caption is centered, otherwise set to a paragraph on the whole line width.

Being a generic class, this is quite a natural setting; if one prefers narrower paragraphs for the captions, the length is a stylistic decision.

\documentclass{book}
\usepackage{showframe}

\begin{document}

\expandafter\def\csname @captype\endcsname{figure}

\caption{This is a short caption}

\caption{This is a longer caption, still on one line}

\caption{This is a much longer caption, which spreads
over two lines; the caption is justified over the whole
line width, but a different setting is not difficult to
obtain.}

\makeatletter
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
\makebox[\hsize][c]{%
\begin{minipage}[t]{.8\hsize}
#1: #2\par
\end{minipage}%
}%
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\makeatother

\caption{This is a much longer caption, which spreads
over two lines; the caption is justified over the whole
line width, but a different setting is not difficult to
obtain.}

\makeatletter
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
\makebox[\hsize][c]{%
\begin{minipage}[t]{.8\hsize}
\centering
#1: #2\par
\end{minipage}%
}%
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\makeatother

\caption{This is a much longer caption, which spreads
over two lines; the caption is justified over the whole
line width, but a different setting is not difficult to
obtain. Let's add some words to make this longer and
uglier when centering each line.}

\end{document}


The redefinition is quite easy, as you see. Higher level packages such as caption should be preferred, of course.