# How do force center-alignment in a caption in a figure?

When I use the following code:

    \documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h!]
\begin{center}
\caption{test}
\includegraphics{intpoptotal.png}
\end{center}
\end{figure}

\end{document}


The caption is centered as I want it, e.g.,

But when I use this apa6 class, with the following code:

    \documentclass{apa6}

\begin{document}

\begin{figure}[h!]
\begin{center}
\caption{test}
\includegraphics{intpoptotal.png}
\end{center}
\end{figure}

\end{document}


The caption is left-aligned, e.g.,

How can I use \documentclass{apa6} with centered captions? And what code in apa6 causes this to happen?

-

## 1 Answer

apa6.cls loads the caption package with the option singlelinecheck=off:

\RequirePackage[singlelinecheck=off]{caption}


this option overrides the standard LaTeX behaviour (automatically center a caption if it fits in one single line). To change this, you can use \captionsetup:

\documentclass{apa6}
\captionsetup{singlelinecheck=on}
\begin{document}

\begin{figure}
\centering
\caption{test}
A
\end{figure}

\end{document}


Notice that this will center only captions that fit on one line; if you want to have all captions centered (whether they span one or more than one line), you can say

\captionsetup{justification=centering}


As a side note, it's preferable to use \centering inside the floating environments instead of the center environment (\centering doesn't add additional vertical space); also, I would suggest you not to use the too restrictive placement specifier [!h].

-
+1 thanks for the added info, I will keep that in mind. – Jay Sullivan Jun 19 '12 at 2:26