# Odd subfigure indexing with minipages

I have two figures in this document. The second uses minipages to keep its subfigures together with a table (as suggested in this answer), unfortunately the subfigures of the second table are not labeled a-b but c-d; likely because they are wrongly seen as a part of the first figure (as shown above).

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}
\renewcommand\thesubtable{(\alph{subtable})}
\usepackage{array}
\usepackage[all]{xy}
% for \extrasrrowheight
%\usepackage{siunitx}

\begin{document}

\begin{figure}
\centering
%ERC1
\begin{subfigure}[b]{0.4\textwidth}
$\xymatrix{ *+[o][F]{C^*} \ar@<-.5ex>[d]_{k_{a1}(R-x_1-x_2)} \\ *+[o][F]{x_1 }\ar@<-.5ex>[u]_{k_{d1}} }$
\caption{Single binding configuration}
\label{ERC1diagram}
\end{subfigure}
%ERC2
\begin{subfigure}[b]{0.4\textwidth}
$\xymatrix{ &*+[o][F]{C^*} \ar@<-.5ex>[dl]_{k_{a1}(R-x_1-x_2)} \ar@<.5ex>[dr]^{k_{a2}(R-x_1-x_2)} & \\ *+[o][F]{x_1 }\ar@<-.5ex>[ur]_{k_{d1}} & & *+[o][F]{x_2 }\ar@<.5ex>[ul]^{k_{d2}} }$
\caption{Two binding configurations}
\label{ERC2diagram}
\end{subfigure}
\caption[Compartmental diagram of the effective rate constant model]{Compartmental diagram of the ERC model with concentration of analyte at the reaction chip's surface $C^*$, and concentrations of bound analyte $x_1(t)$ and $x_2(t)$.}
\label{ERCdiagram}
\end{figure}
\noindent
\begin{figure}
\centering
%VIs
\begin{minipage}[b]{0.45\textwidth}
%\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{ERC_Kd_varies_a2.png}
\captionof{subfigure}{Association phase}
\label{Lng1AssPhase}
%\end{subfigure}
\end{minipage}
\begin{minipage}[b]{0.45\textwidth}
%\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{ERC_Kd_varies_d3.png}
\captionof{subfigure}{Dissociation phase}
\label{Lng1AssPhase}
%\end{subfigure}
\end{minipage}\\
\begin{minipage}[b]{1\textwidth}
%\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[scale=1.2]{ERC_kd_varies_legend4.png}
\end{minipage}%{subfigure}
\caption{Graphs of bound antibody $x_1$ against time $t$ for the Langmuir single configuration model (green dashed line) and the ERC model for different values of $k_m$.}
%\captionof{figure}{Graphs of bound antibody $x_1$ against time $t$ for the Langmuir single configuration model (green dashed line) and the ERC model for different values of $k_m$.}
\label{fig:kc_varies}
%\end{figure}
%\begin{table}
\vspace{\floatsep}
\centering
\footnotesize
\begin{tabular}
{ | c | c | c | c | c |  }
\hline
Parameter           &$k_{a}$                   & $k_{d}$ &     $R$                   & $C_T$   \\
&M$^{-1}$s$^{-1}$ &s$^{-1}$& pg nm$^{-2}$ & nM   \\\hline
Value                  &6E-4                       &7E-3        & 500 & 100   \\\hline
\end{tabular}
\captionof{table}{Values taken by parameters in Fig. \ref{fig:kc_varies} that are not varied}
\label{tab:LwTsols}
\end{figure}
\end{document}

• The subfigure environment is more or less a minipage environment that can have a \caption inside it. If simply replacing minipage by subfigure and using a plain \caption doesn't work for you, you can use \setcounter{subfigure}{0} before the first minipage (in the second) figure to reset the numbering. The \captionof doesn't know that this minipage is in another float, so it doesn't know it's supposed to reset the numbering, so you have to do it manually or use subfigure. Oct 23, 2018 at 21:29
• Thanks thats all helpful information, but using subfigure/caption didn't help- thats how I ended up using minipage. I'd like to find a better solution than using setcounter - but its a good workaround for now. Oct 23, 2018 at 23:21
• @JohnKormylo The next step of using minipage with \subcaption is using subfigure with \caption since subfigure is actually a minipage with \caption = \subcaption (and a different hyperref anchor placing). See my answer below.
– user2574
Oct 24, 2018 at 16:58

\captionof is only intended to use with floating environments like figure or table, but not with sub-environments like subfigure or subtable. Unfortunately this leads into weird behaviour and wrong formatting instead of an error message. [1]

Use \subcaption instead:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}
\renewcommand\thesubtable{(\alph{subtable})}
\usepackage{array}
\usepackage[all]{xy}
% for \extrasrrowheight
%\usepackage{siunitx}

\begin{document}

\begin{figure}
\centering
%ERC1
\begin{subfigure}[b]{0.4\textwidth}
$\xymatrix{ *+[o][F]{C^*} \ar@[d]_{k_{a1}(R-x_1-x_2)} \\ *+[o][F]{x_1 }\ar@[u]_{k_{d1}} }$
\caption{Single binding configuration}
\label{ERC1diagram}
\end{subfigure}
%ERC2
\begin{subfigure}[b]{0.4\textwidth}
$\xymatrix{ &*+[o][F]{C^*} \ar@[dl]_{k_{a1}(R-x_1-x_2)} \ar@[dr]^{k_{a2}(R-x_1-x_2)} & \\ *+[o][F]{x_1 }\ar@[ur]_{k_{d1}} & & *+[o][F]{x_2 }\ar@[ul]^{k_{d2}} }$
\caption{Two binding configurations}
\label{ERC2diagram}
\end{subfigure}
\caption[Compartmental diagram of the effective rate constant model]{Compartmental diagram of the ERC model with concentration of analyte at the reaction chip's surface $C^*$, and concentrations of bound analyte $x_1(t)$ and $x_2(t)$.}
\label{ERCdiagram}
\end{figure}
\noindent
\begin{figure}
\centering
%VIs
\begin{minipage}[b]{0.45\textwidth}
%\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{ERC_Kd_varies_a2.png}
\subcaption{Association phase}
\label{Lng1AssPhase}
%\end{subfigure}
\end{minipage}
\begin{minipage}[b]{0.45\textwidth}
%\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{ERC_Kd_varies_d3.png}
\subcaption{Dissociation phase}
\label{Lng1AssPhase}
%\end{subfigure}
\end{minipage}\\
\begin{minipage}[b]{1\textwidth}
%\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[scale=1.2]{ERC_kd_varies_legend4.png}
\end{minipage}%{subfigure}
\caption{Graphs of bound antibody $x_1$ against time $t$ for the Langmuir single configuration model (green dashed line) and the ERC model for different values of $k_m$.}
%\captionof{figure}{Graphs of bound antibody $x_1$ against time $t$ for the Langmuir single configuration model (green dashed line) and the ERC model for different values of $k_m$.}
\label{fig:kc_varies}
%\end{figure}
%\begin{table}
\vspace{\floatsep}
\centering
\footnotesize
\begin{tabular}
{ | c | c | c | c | c |  }
\hline
Parameter           &$k_{a}$                   & $k_{d}$ &     $R$                   & $C_T$   \\
&M$^{-1}$s$^{-1}$ &s$^{-1}$& pg nm$^{-2}$ & nM   \\\hline
Value                  &6E-4                       &7E-3        & 500 & 100   \\\hline
\end{tabular}
\captionof{table}{Values taken by parameters in Fig. \ref{fig:kc_varies} that are not varied}
\label{tab:LwTsols}
\end{figure}
\end{document}


And since the subfigure environment is nothing more than a minipage with \caption enabled, this could be written as:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}
\renewcommand\thesubtable{(\alph{subtable})}
\usepackage{array}
\usepackage[all]{xy}
% for \extrasrrowheight
%\usepackage{siunitx}

\begin{document}

\begin{figure}
\centering
%ERC1
\begin{subfigure}[b]{0.4\textwidth}
$\xymatrix{ *+[o][F]{C^*} \ar@[d]_{k_{a1}(R-x_1-x_2)} \\ *+[o][F]{x_1 }\ar@[u]_{k_{d1}} }$
\caption{Single binding configuration}
\label{ERC1diagram}
\end{subfigure}
%ERC2
\begin{subfigure}[b]{0.4\textwidth}
$\xymatrix{ &*+[o][F]{C^*} \ar@[dl]_{k_{a1}(R-x_1-x_2)} \ar@[dr]^{k_{a2}(R-x_1-x_2)} & \\ *+[o][F]{x_1 }\ar@[ur]_{k_{d1}} & & *+[o][F]{x_2 }\ar@[ul]^{k_{d2}} }$
\caption{Two binding configurations}
\label{ERC2diagram}
\end{subfigure}
\caption[Compartmental diagram of the effective rate constant model]{Compartmental diagram of the ERC model with concentration of analyte at the reaction chip's surface $C^*$, and concentrations of bound analyte $x_1(t)$ and $x_2(t)$.}
\label{ERCdiagram}
\end{figure}
\noindent
\begin{figure}
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{ERC_Kd_varies_a2.png}
\caption{Association phase}
\label{Lng1AssPhase}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{ERC_Kd_varies_d3.png}
\caption{Dissociation phase}
\label{Lng1AssPhase}
\end{subfigure}\\
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[scale=1.2]{ERC_kd_varies_legend4.png}
\end{subfigure}
\caption{Graphs of bound antibody $x_1$ against time $t$ for the Langmuir single configuration model (green dashed line) and the ERC model for different values of $k_m$.}
%\captionof{figure}{Graphs of bound antibody $x_1$ against time $t$ for the Langmuir single configuration model (green dashed line) and the ERC model for different values of $k_m$.}
\label{fig:kc_varies}
%\end{figure}
%\begin{table}
\vspace{\floatsep}
\centering
\footnotesize
\begin{tabular}
{ | c | c | c | c | c |  }
\hline
Parameter           &$k_{a}$                   & $k_{d}$ &     $R$                   & $C_T$   \\
&M$^{-1}$s$^{-1}$ &s$^{-1}$& pg nm$^{-2}$ & nM   \\\hline
Value                  &6E-4                       &7E-3        & 500 & 100   \\\hline
\end{tabular}
\captionof{table}{Values taken by parameters in Fig. \ref{fig:kc_varies} that are not varied}
\label{tab:LwTsols}
\end{figure}
\end{document}