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.

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}
share|improve this question
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Jan 21 at 18:47
    
Does my answer solve your problem? –  karlkoeller Jan 22 at 15:16
    
It absolutely did. Thank you very much! –  Tano Jan 23 at 11:30
    
Happy to help :-) –  karlkoeller Jan 23 at 12:16

1 Answer 1

up vote 3 down vote accepted

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:

enter image description here

share|improve this answer
    
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 at 23:45

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.