Numbering Captions – How to Caption Nested Subfigures with Subcaption

captionsnumberingsubcaption

The following creates a figure with three images arranged appropriately. If I remove the two \caption{} lines, it numbers the main subfigures as I'd like, and keeping the two \caption{} lines puts subfigure letters in the right place for the sub-subfigures, but the letters are wrong.

How can I change the subfigure identification from a, b, c, d to a, b1, b2, b or something similar?

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{fancyref}
\usepackage{subcaption}
\begin{document}
\begin{figure}
  \begin{subfigure}{0.5\textwidth}
    \centering
    \includegraphics[width=\textwidth]{wu8_wedges}
    \caption{With wedges.}
    \label{fig:wedges}
  \end{subfigure}
  \begin{subfigure}{0.5\textwidth}
    \begin{subfigure}{\textwidth}
      \centering
      \includegraphics[width=\textwidth]{wu8_flat1}
      \caption{}
      \label{fig:flat1}
    \end{subfigure}
    \begin{subfigure}{\textwidth}
      \centering
      \includegraphics[width=\textwidth]{wu8_flat2}
      \caption{}
      \label{fig:flat2}
    \end{subfigure}
    \caption{Without wedges}
    \label{fig:flat}
  \end{subfigure}
  \caption{Interactions between the railcar and the man's feet.}
  \label{fig:interactions}
\end{figure}
\end{document}

Best Answer

One possibility would be to manually adjust the counters and \thesubfigure:

\documentclass{article}
\usepackage{amsmath}
\usepackage[demo]{graphicx}
\usepackage{fancyref}
\usepackage{subcaption}

\begin{document}

\begin{figure}
  \begin{subfigure}{0.5\textwidth}
    \centering
    \includegraphics[width=.95\textwidth]{wu8_wedges}
    \caption{With wedges.}
    \label{fig:wedges}
  \end{subfigure}%
  \begin{subfigure}{0.5\textwidth}
    \begin{subfigure}{\textwidth}
      \renewcommand\thesubfigure{\alph{subfigure}1}
      \centering
      \includegraphics[width=.95\textwidth]{wu8_flat1}
      \caption{}
      \label{fig:flat1}
    \end{subfigure}
    \begin{subfigure}{\textwidth}
      \addtocounter{subfigure}{-1}
      \renewcommand\thesubfigure{\alph{subfigure}2}
      \centering
      \includegraphics[width=.95\textwidth]{wu8_flat2}
      \caption{}
      \label{fig:flat2}
    \end{subfigure}
    \addtocounter{subfigure}{-1}
    \caption{Without wedges}
    \label{fig:flat}
  \end{subfigure}
  \caption{Interactions between the railcar and the man's feet.}
  \label{fig:interactions}
\end{figure}

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.