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 have the following document:

\documentclass{article}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{geometry}
\setcaptionwidth{12cm}
\begin{document}
\begin{figure}[t]
  \centering%
  \subfloat[]{\label{figa}\includegraphics[width=38mm,%
    height=32.48mm]{fig1}}\hspace{3mm}%
  \subfloat[]{\label{figb}\includegraphics[width=38mm,%
    height=32.48mm]{fig2}}\hspace{3mm}%
  \subfloat[]{\label{figc}\includegraphics[width=38mm,%
    height=32.48mm]{fig3}}%
  \caption{Some caption.}
  \label{fig-moire-comp-xue}
\end{figure}
\end{document}

I want the captions of all figures to have a width of 12cm (slightly less than main body text), and have TeX generate the (a), (b) labels for me.

This is the result:

Incorrect image

If I then comment out the line in the preamble setting the caption width to 12cm, it aligns as I want:

Correct image

(This is an issue in my thesis, a much more complicated document, but I think I have narrowed it down to this conflict.) I just want the alignment to be fixed, but still have 12cm wide captions for all figures.

I don't really care if the solution is an ugly per-figure hack, I just care about alignment.

Thanks for any help.

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

You can set globally the caption's width and separately the subcaption's width:

\captionsetup{width=12cm}
\captionsetup[subfloat]{margin=0pt}

Don't use \setcaptionwidth, of course (it is an obsolete command of caption version 2).w

share|improve this answer
    
Thank you, that works perfectly! –  Chris Poole Jan 12 '12 at 12:32
add comment

set the captionwidth before the caption itself:

\documentclass{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\usepackage{geometry}
\begin{document}
\begin{figure}
  \centering%
  \subfloat[]{\label{figa}\includegraphics[width=38mm,%
    height=32.48mm]{fig1}}\hspace{3mm}%
  \subfloat[]{\label{figb}\includegraphics[width=38mm,%
    height=32.48mm]{fig2}}\hspace{3mm}%
  \subfloat[]{\label{figc}\includegraphics[width=38mm,%
    height=32.48mm]{fig3}}%
  \setcaptionwidth{12cm}
  \caption{Some very long caption to show that is not
           wider than 12 cm as defined by the setting.}
  \label{fig-moire-comp-xue}
\end{figure}
\end{document}
share|improve this answer
add comment

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.