[Tex/LaTex] Nested subfloats with detailed caption control

captionssubcaptionsubfloats

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}

Best Answer

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}