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.

How do I get subfig-like captions for a single figure? I've got images that have multiple panels each, and I'd like to make a caption for all the sub-panels, as well as be able to reference each sub-panel. Something like Fig 1A, 1B etc.

Update This is what I've come up with, based on Werner's answer:

\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{letterpaper}

\usepackage{graphicx}

\usepackage[labelformat=simple]{caption,subcaption}
\usepackage{hyperref}
\usepackage{varioref}

\renewcommand\thesubfigure{\Alph{subfigure}}

\begin{document}

Tofu gluten-free VHS locavore, viral williamsburg +1 cliche fanny pack leggings terry richardson cred photo booth artisan. Echo park locavore jean shorts shoreditch before they sold out, farm-to-table keytar high life banksy tofu sartorial marfa. Gentrify butcher leggings 

\captionsetup{singlelinecheck=false}

\begin{figure}[htb]
    \includegraphics[scale=1]{figure2}
    \caption{This is a general heading for figure 1.}\label{fig:1}

    \subcaptionbox{This is something about figure 1A.}[\linewidth]{\label{fig:1a}}
    \subcaptionbox{This is more more more more more more more more more more text about figure 1B. Sustainable terry richardson craft beer homo, cardigan wayfarers blog commodo DIY quinoa sartorial american apparel nostrud.\label{fig:1b}}[\linewidth]  {}


\end{figure}

Here's a ref to fig \vref{fig:1b}.Skateboard tempor hoodie helvetica quis. Sustainable terry richardson craft beer homo, cardigan wayfarers blog commodo DIY quinoa sartorial american apparel nostrud. Williamsburg aute mcsweeney's wes anderson. Dolor eiusmod tempor assumenda stumptown, delectus irony laboris 


\end{document}  
share|improve this question

1 Answer 1

up vote 2 down vote accepted

This example, slightly altered from the subcaption package documentation is probably what you're looking for (\rule is meant for illustration only):

\documentclass{article}
\usepackage{caption,subcaption}
\begin{document}
\begin{figure}
  \hfill\subcaptionbox{A subfigure\label{fig:1a}}[8em]{\centering \rule{5pt}{3em}}
  \hfill\subcaptionbox{Another subfigure\label{fig:1b}}{\centering \rule{10em}{2em}}
  \hfill\subcaptionbox{A final subfigure\label{fig:1c}}[9em]{\centering \rule{2em}{4em}}
  \hfill\null
  \caption{A figure}\label{fig:1}
\end{figure}
Look at Figure~\ref{fig:1a} and~\ref{fig:1b}, or even Figure~\ref{fig:1c}. Everything is contained in Figure~\ref{fig:1}.
\end{document}

Subfigures in a figure

The subcaption package necessarily requires its contents to be typeset in a box. As such, the use of the \subcaptionbox{<heading>}[<width>][<inner-pos>]{<contents>} is ideal to have possible variable-width (the <width> argument is optional) contents with a subcaption. Without the <width> specification, the subfigure will be put in a box of "natural width" equivalent to the width of <contents>. So, if you have images that are very wide, you don't have to worry about specifying <width>. However, for a very narrow <contents> specifying <width> will allow for correct typesetting of the caption.

Also, there are ways to manipulate the representation of the your (sub-)captions and references.

share|improve this answer
    
this seems to work, though what does it mean when it says "Please note that the \subcaption command must be applied inside its own box or environment"? –  Noah Aug 16 '11 at 18:55
    
This was done by design, and hence the typesetting of \subcaption inside a minipage. Alternatively, you could use the \subcationbox{<heading>}[<width>][<inner-pos>]{<contents>} and insert \label{...} inside <heading>. –  Werner Aug 16 '11 at 19:02
    
Perhaps you can add more content to your original question in the form of an MWE. That way we can see what problems you are experiencing. For example, merely stating that it "doesn't seem to work here" is vague. There may be many alternatives to what you're asking, but without more detail it's difficult to assess adequately your needs. –  Werner Aug 16 '11 at 19:33
    
@Noah: In terms of compatibility in your code (and ultimately longevity), here's something to consider: subcaption vs. subfig. That's why I leaned towards subcaption, which then forces you to use boxes. What is wrong with the boxes? Also do you have subfigures that span \textwidth, or do you just want your caption to span \textwidth? –  Werner Aug 16 '11 at 20:04
1  
@Noah: If you want captions to span the entire width, then use \linewidth rather than \textwidth. I've updated my answer with some description of this. The subcaption package allows to fix your subfigure with. If this is what you want, then use \subcaptionbox{<heading>}[\linewidth]{<contents>}. –  Werner Aug 16 '11 at 20:50

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.