0

For reasons, I need a specific numbering for my subfigures in a figure environment. I want the caption of the figure environment to refer to the subfigures as follows: Figures 1-4. How can I do that?

\documentclass[twocolumn]{article}
\usepackage{graphicx}
\usepackage[caption=false]{subfig}

\begin{document}
\newcommand{\gridsize}{0.45}
\begin{figure*}[t!]
\centering
\renewcommand{\thesubfigure}{\thefigure}
\subfloat[Subfigure (1)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image-a}
    \label{fig:subfig1}
}
\renewcommand{\thesubfigure}{\thefigure\alph{subfigure}}
\setcounter{figure}{1}
\setcounter{subfigure}{0}
\subfloat[Subfigure (2a)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image-b}
    \label{fig:subfig2a}
}
\setcounter{figure}{1}
\setcounter{subfigure}{1}
\subfloat[Subfigure (2b)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image-b}
    \label{fig:subfig2b}
}
\setcounter{figure}{1}
\setcounter{subfigure}{2}
\subfloat[Subfigure (2c)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image-b}
    \label{fig:subfig2c}
}\\
\renewcommand{\thesubfigure}{\thefigure}
\setcounter{figure}{2}
\setcounter{subfigure}{0}
\subfloat[Subfigure (3)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image-c}
    \label{fig:subfig3}
}
\renewcommand{\thesubfigure}{\thefigure\alph{subfigure}}
\setcounter{figure}{3}
\setcounter{subfigure}{0}
\subfloat[Subfigure (4a)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image}
    \label{fig:subfig4a}
}
\setcounter{figure}{3}
\setcounter{subfigure}{1}
\subfloat[Subfigure (4b)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image}
    \label{fig:subfig4b}
}
\setcounter{figure}{3}
\setcounter{subfigure}{2}
\subfloat[Subfigure (4c)]{
    \includegraphics[width=\gridsize\columnwidth]{example-image}
    \label{fig:subfig4c}
}
\label{fig:figure}
\caption{Main caption}
\end{figure*}
\end{document}

Thanks for your help,

2
  • 1
    Welcome to TeX.SX! Please complete your fragment to a compilable example!
    – user31729
    Aug 24 '16 at 14:18
  • My example is now compilable, my problem is to have Figures 1-4 in the numbering of the main caption instead of Figure 4 as it is right now. I would also like to have 1-4 where I refer to the main figure environment label.
    – Maveric78f
    Aug 25 '16 at 15:00
1

Since you didn't provide actual subfigure captions, I tried to adapt.

\documentclass[twocolumn]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure*}[t!]
    \centering
    \begin{minipage}{.49\columnwidth}
        \caption{Subfigure (\alph{figure})}
        \includegraphics[width=\textwidth]{example-image-a}
        \label{fig:subfig1}
    \end{minipage}
    \begin{minipage}{.49\columnwidth}
        \caption{Subfigure (\alph{figure})}
        \includegraphics[width=\textwidth]{example-image-b}
        \label{fig:subfig2}
    \end{minipage}
    \begin{minipage}{.49\columnwidth}
        \caption{Subfigure (\alph{figure})}
        \includegraphics[width=\textwidth]{example-image-c}
        \label{fig:subfig3}
    \end{minipage}
    \begin{minipage}{.49\columnwidth}
        \caption{Subfigure (\alph{figure})}
        \includegraphics[width=\textwidth]{example-image}
        \label{fig:subfig4}
    \end{minipage}
    Main Caption% will not increment figure counter nor appear in list of figures
\end{figure*}
\end{document}

demo

2
  • Thanks. By removing the \caption{}, I can manually define the title of the main caption, which is a sort of a solution. But I would still be interested in a dynamic solution to my problem.
    – Maveric78f
    Aug 25 '16 at 15:03
  • If you want to add something to the list of figures, see tex.stackexchange.com/questions/43869/… Aug 25 '16 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.