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 four images, each with a corresponding magnified version of a small portion of it. I would like to arrange them so that the zoomed out versions are on one row side by side, and the corresponding zoomed versions are under them on a second row.

Then, I'd like there to only be subfloat caption numbers (a,b,c...) under the lower row so that a refers to both the full view and zoomed view.

I tried modifying Thorsten Donig's example from here: Suppress Numbering of Subfigures, with the result being the code below which DOES DO what I want.

So, my question is, is my approach a smart way to do what I want, or is there a better way to get the effect of nested subfigs with granular caption control?

Thanks.

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=3cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{blindtext}
\usepackage{subfig}

\title{Two subfigures without a caption}
\author{Myx}

\begin{document}
  \maketitle
  \blindtext

\begin{figure}[!htbp]
  \centering
    \captionsetup[subfigure]{labelformat=empty} % Turn off label display. Label counter keep counting silently
    % First row of figures (with no labels)
    \subfloat[]{
        \subfloat[]{
            \rule{6.4cm}{3.6cm}
        }
        \hspace{10pt}
        \subfloat[]{
            \rule{6.4cm}{3.6cm}
        }
    }

    % Second row of figures (with labels)
    \subfloat[]{
    \setcounter{subfigure}{0} % Reset label counter so next subfig starts at `a`
    \captionsetup[subfigure]{labelformat=default} % Turn label display back on
    \subfloat[]{
        \rule{6.4cm}{3.6cm}
    }
    \hspace{10pt}
    \subfloat[]{
        \rule{6.4cm}{3.6cm}
    }
    }

  \caption[Nested Subfloats]{Top row should have no captions, bottom row should start caption number at 'a'. }
  \label{fig.nested}
\end{figure}


  \blindtext
\end{document}
share|improve this question

3 Answers 3

up vote 2 down vote accepted

I would use the subcaption package instead of subfig (the reason can be found in subcaption vs. subfig). Since only the bottom row will receive captions, there's is no need to place the top row inside subfigure environments, and minipages can be used to achiev the desired alignment. One possible way to achieve what you want using subcaption is the following:

\documentclass[11pt,a4paper,english]{article}
\usepackage[includeheadfoot,margin=3cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}[!htbp]
  \captionsetup[subfigure]{labelformat=simple}
  \begin{minipage}[b]{.5\linewidth}
    \centering
    \rule{6.4cm}{3.6cm}
  \end{minipage}%
  \begin{minipage}[b]{.5\linewidth}
    \centering
    \rule{6.4cm}{3.6cm}
  \end{minipage}\\[2em]
  \begin{subfigure}[b]{.5\linewidth}
    \centering
    \rule{6.4cm}{3.6cm}
    \caption{}
    \label{fig:sub3}
  \end{subfigure}%
  \begin{subfigure}[b]{.5\linewidth}
    \centering
    \rule{6.4cm}{3.6cm}
    \caption{}
    \label{fig:sub4}
  \end{subfigure}%
  \caption{A figure with four subfigures}
  \label{fig:test}
\end{figure}

\end{document}

share|improve this answer

You basically want to label only columns, right? Then I would suggest the following.

Arrange your figures using subfloat and reset the counter before adding the captions.

\documentclass{article}

\usepackage{subfig}

\makeatletter
\newcommand{\clearsubcaptcounter}{\setcounter{sub\@captype}{0}}
\makeatother

\begin{document}

\begin{figure}
  \centering
  \subfloat{\rule{4cm}{4cm}}
  \hspace{1em}
  \subfloat{\rule{4cm}{4cm}}\\
  \clearsubcaptcounter
  \subfloat[Column 1]{\rule{4cm}{4cm}}
  \hspace{1em}
  \subfloat[Column 2]{\rule{4cm}{4cm}}
\end{figure}

\end{document}

The command \clearsubcaptioncounter resets the labeling of the captions.

share|improve this answer
    
Welcome to TeX.SX! –  Papiro Jul 29 '13 at 13:52

The only reason I would use subfig and its \subfloat macro is to get sub-figure captions. So why use it at all if you don't want them? You are not forced to wrap all your images inside a figure inside \subfloat. Just place the \includegraphics (or other) macros in it. If you want to align them in a special way with the the other images which have captions you could place them into a minipages. Alternatively you can stack two images inside one \subfloat so they only get one caption. There is no rule which stops you from putting more than one image or other code into a \subfloat or main float.

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=3cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{blindtext}
\usepackage{subfig}

\title{Two subfigures without a caption}
\author{Myx}

\begin{document}
  \maketitle
  \blindtext

\begin{figure}[!htbp]
    \centering
    % First row of images (with no labels)
    \rule{6.4cm}{3.6cm}%
    \hspace{10pt}%
    \rule{6.4cm}{3.6cm}%

    % Second row of images (with labels)
    \subfloat[]{%
        \rule{6.4cm}{3.6cm}%
    }%
    \hspace{10pt}%
    \subfloat[]{%
        \rule{6.4cm}{3.6cm}%
    }%

  \captionof{figure}[Nested Subfloats]{Top row should have no captions, bottom row should start caption number at 'a'. }
  \label{fig.nested}
\end{figure}


  \blindtext
\end{document}

Result

share|improve this answer

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.