# Centering Subcaptions including a linebreak

I found an asnwered question concerning this topic already here: Centering a subcaption Copying \captionsetup[subfigure]{justification=centering} doesn't help me thought for I am using different packages.

I would like my Captions and Subcaptions to be justified as the text below. Just under my pictures. Any suggestions?

Thanks a lot

\documentclass{article}
\usepackage{subfig}
\usepackage[labelfont=bf, justification=justified]{caption}
\usepackage[demo]{graphicx}% Remove demo option in real document

\begin{document}
\begin{figure}
%   \captionsetup[subfigure]{justification=centering}
\centering
\subfloat[Subcaption one \newline including a linebreak ]   {
\includegraphics[width=0.2\textwidth]{image1}
}
\hspace{1cm}
\subfloat[Subcaption two \newline including a linebreak]
{
\includegraphics[width=0.2\textwidth]{image2}
}
\caption{Figure caption \newline with additional text right here}
\end{figure}

\begin{center}
This is correctly justified Text \\ including a longer linebreak than blabla.
\end{center}
\end{document}

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Jan 21 '14 at 18:47
Does my answer solve your problem? – karlkoeller Jan 22 '14 at 15:16
It absolutely did. Thank you very much! – Tano Jan 23 '14 at 11:30
Happy to help :-) – karlkoeller Jan 23 '14 at 12:16

The command \subfloat has two optional arguments, the first being the LoF entry.

So, substituting lines like

\subfloat[Subcaption one \newline including a linebreak]


with

\subfloat[Subcaption one including a linebreak][Subcaption one \\ including a linebreak]


does the job.

MWE (I've also removed some spurious spaces with %)

\documentclass{article}
\usepackage{subfig}
\usepackage[labelfont=bf, justification=justified]{caption}
\usepackage[demo]{graphicx}% Remove demo option in real document

\begin{document}
\begin{figure}
\captionsetup[subfigure]{justification=centering}
\centering
\subfloat[Subcaption one including a linebreak][Subcaption one \\ including a linebreak]
{%
\includegraphics[width=0.2\textwidth]{image1}%
}%
\hspace{1cm}%
\subfloat[Subcaption two including a linebreak][Subcaption two \\ including a linebreak]
{%
\includegraphics[width=0.2\textwidth]{image2}%
}
\caption{Figure caption \\ with additional text right here}
\end{figure}

\begin{center}
This is correctly justified Text \\ including a longer linebreak than blabla.
\end{center}

\end{document}


Output:

-
Do you have to do anything special to allow \ in the subcaptions? I get errors whereas \newline works fine. This is in a rather complex document so I just wondered if there's anything I can check for easily as I've never used subfig before. (If not, I might try to create an MWE but I'll probably just use \newline even if I really ought not.) – cfr May 21 '14 at 23:45