11

How do I left-align the captions on the subfigures below, so that the caption starts aligned with the left-hand edge of the corresponding subfigure?

enter image description here

\documentclass{article}

\usepackage[draft]{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}[H]
\begin{center}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S}
\caption{workflow $S$}
\end{subfigure}
\begin{subfigure}[b]{0.5\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S-run}
\caption{run of $S$}
\end{subfigure}

\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S'}
\caption{workflow $S'$}
\end{subfigure}
\begin{subfigure}[b]{0.5\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S'-run}
\caption{run of $S'$}
\end{subfigure}
\end{center}
\end{figure}

\end{document}

There seem to be many related questions, but none that specifically addresses this.

1 Answer 1

14

Add this line to your preamble,

\captionsetup[subfigure]{justification=justified,singlelinecheck=false}

That will affect all the subfigure captions. For details (and other options), please keep reading on.


As is pointed out in the caption package documentation,

As addition to the caption format you could also specify a caption justification; it is specified with the option justification=<justification name>.

You can choose one of the following:

justified: Typesets the caption as a normal paragraph.

......

singlelinecheck= The standard LaTeX document classes (article, report, and book) automatically center a caption if it fits in one single line. The caption package adapts this behavior and therefore usually ignores the justification & indention you have set with justification= & indention= in such case. But you can switch this special treatment of such short captions off with the option singlelinecheck=false.

Now since you want only the subfigure captions to be left justified, you need to use the \captionsetup[FLOAT_TYPE]{OPTIONS} command.

FLOAT_TYPE can be table, figure, subtable and subfigure and specifies what type of caption that particular \captionsetup command applies to. So you can set different options for each of the figure, table, subfigure and subtable floats individually.

In your case the FLOAT_TYPE will be subfigure. If you put that \captionsetup command in the preamble, all your subfigure captions will be left justified. If you put that at some midpoint, all subsequent ones will get that effect. Should you need that for only one figure, put that inside that particular figure environment.


Here is the output.

enter image description here

6
  • 3
    It should be possible to do this only for subfigure captions.
    – egreg
    Commented Jan 6, 2014 at 16:23
  • @egreg Oops. Get your point.
    – Masroor
    Commented Jan 6, 2014 at 16:30
  • Just being fussy. ;-) A good answer has become an excellent one.
    – egreg
    Commented Jan 6, 2014 at 16:48
  • @egreg Thanks are not norm here, but can not help thanking you. (And will follow the norm and upvote the comment.) :-)
    – Masroor
    Commented Jan 6, 2014 at 16:50
  • Does the trick. (I had scanned the subcaption documentation but didn't think to look at the caption package.) Thanks!
    – Roly
    Commented Jan 6, 2014 at 20:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .