# How to include 3 vertically aligned subfigures, while making them appear as 3 separate “Main” (and not sub-) figures?

I want to place 3 figures on top of each other and I figured out a way to do that using subcaption package. But, they appear as sub-figures and not the "main" figures. I think it's because of the package I used, but I found it very hard to place 3 figures on top of each other, if I just used 3 separate \begin{figure}, so I used this. Can I still use subcaption and turn them into "main" figures. I want to use subcaption because I was able to do what I needed, instantly, so I really like how simple it is. Also, there are other problems:

1. The "main" figure title shows up and I can't hide it.
2. This title and 3 figures are not properly placed at centre.
3. Also, the titles of 3 figures are pushed right! I want everything in centre and aligned nicely.
4. The figure title numbers are like this - (a), (b) and I want them to be like 1.: Title, like how the main title shows, but in bold font.

Is it possible to do? Here's what I've used:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\caption{First SUB-FLOAT}
\label{fig:demo1}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\caption{Second SUB-FLOAT}
\label{fig:demo2}
\end{subfigure}
\begin{subfigure}{0.56\textwidth}
\includegraphics{}
\caption{Third SUB-FLOAT}
\label{fig:demo3}
\end{subfigure}
\caption{Demo}
\end{figure}
\end{document}


And it looks like this:

• you just need three \caption commands, not subfigure at all. – David Carlisle May 31 '15 at 10:21
• @DavidCarlisle yes, but doing so would mean that I loose the control over figure environment caption, if I need to revert back to a more standard figure-subfigure setup. My answer given below sheds more light on how it allows me to revert back to a standard setup, if need be, by simply modifying the \captionsetup variables for both the figure & subfigure environments. – Amar May 31 '15 at 16:01

You can use the last code shown here to achieve what you want without using subcaption package at all.

But, since your question is specifically regarding how you can achieve your result using subcaption package, here's a solution to your problems.

Now, there are several "essential" bits missing from your code. So, let's look at them one by one:

1. You include only the subcaption package. It's always better to load both the caption and the subcaption packages together, in that order. As, caption package will allow you to customise all sorts of float captions with great flexibility.

2. Instead of using \usepackage[demo]{graphicx}, you may use the mwe package to display example images. The black boxes are replaced by better looking grey-scale images.

3. The horizontal alignment of your figures & captions goes off-centre, because you've used \centering only once for the outer figure environment. For proper alignment, you must repeat \centering in all 3 subfigure environments as well.

4. Also, it's better to use \includegraphics[width=\textwidth]{example-image-a} after \begin{subfigure}{0.56\textwidth} than using \includegraphics{example-image-a}; as it will help achieving the proper scaling of your images.

5. Another problem with your code, and this is a big one, is that you are missing the mandatory empty-line between two subfigure environments. See this for further explanation. You don't see any difference due to the image scaling you have chosen. As an experiment, change \begin{subfigure}{0.56\textwidth} to \begin{subfigure}{0.2\textwidth} and see what happens. If you want 3 figures aligned vertically, one top of another, you have to maintain the all essential empty-line between two sub-figures.

%%%%%% begin: caption/subcaption setup %%%%%%
\renewcommand\thefigure{Main-\arabic{figure}}
\DeclareCaptionLabelFormat{simplab}{Figure~#2}
\DeclareCaptionFormat{nocap}{}
\DeclareCaptionSubType*{figure}
\renewcommand\thesubfigure{\arabic{subfigure}}
\captionsetup[subfigure]{%
font={normalsize},
labelfont={bf},
labelformat=simplab,
labelsep=colon,
singlelinecheck=true,
position=bottom
}%
%%%%%% end: caption/subcaption setup %%%%%%

• The first definition, \renewcommand\thefigure{Main-\arabic{figure}} is not absolutely essential in this case, but it helps to differentiate the reference to the main figure (if needed in future) from your pseudo-subfigures, since you need them to look exactly like the main figures!
• \DeclareCaptionLabelFormat{}{} & \DeclareCaptionFormat{}{} are from the caption package; whereas, \captionsetup[subfigure]{} & \DeclareCaptionSubType*{figure} are from the subcaption package. For further information, please look at the package documentation of caption & subcaption.
• \DeclareCaptionFormat{nocap}{} defines a special empty-caption format for main figure environments.
• \DeclareCaptionLabelFormat{simplab}{Figure~#2} defines how the figure labels are typeset.
• \captionsetup[subfigure]{} sets up the subfigure caption font size to normalsize, label to \bfseries, label separator to colon and label format to simplab which is defined earlier using \DeclareCaptionFormat{}{}.
• Moreover, to hide the main figure caption, we use format=nocap in the \captionsetup{} of the main figure caption. The nocap format was defined earlier using \DeclareCaptionFormat{}{}.

There's actually no real need to do this, because hiding the main caption is as simple as commenting out the \caption{} line using %. However, if the user still wants to refer to these 3 figures collectively, the main caption will have to be present and active (i.e. uncommented). Whichever is the case, I find it most practical just to define a custom empty-caption format and switch between the normal & the empty formats as needed, while retaining the entire caption line as it is, than to completely remove it. If, in future, the user decides to print the main caption, it is already there at the switch of a label format! Isn't that convenient? :) .. See it yourself by deleting format=nocap from the \captionsetup{} of the main figure caption!

I have also included the reference to main caption inside subcaptions, just to show that even though the main caption doesn't show up in the output PDF, it is very much valid/ active and its label can be referenced easily.

Here's the MWE code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{mwe}    % for example figures!
%%%%%% begin: caption/subcaption setup %%%%%%
\renewcommand\thefigure{Main-\arabic{figure}}
\DeclareCaptionLabelFormat{simplab}{Figure~#2}
\DeclareCaptionFormat{nocap}{}
\DeclareCaptionSubType*{figure}
\renewcommand\thesubfigure{\arabic{subfigure}}
\captionsetup[subfigure]{%
font={normalsize},
labelfont={bf},
labelformat=simplab,
labelsep=colon,
singlelinecheck=true,
position=bottom
}%
%%%%%% end: caption/subcaption setup %%%%%%
\pagestyle{empty}
\begin{document}
\begin{figure}[htbp]
\centering
\vspace*{5pt}%
\hspace*{\fill}%
\begin{subfigure}{0.56\textwidth}     % start subfigure 1
%\belowcaptionskip=8pt
\centering
\includegraphics[width=\textwidth]{example-image-a}%
\captionsetup{skip=12pt}%
\caption{First SUB-FLOAT (\ref{fig:demoMain})}
\label{fig:demo1}
\end{subfigure}%          % end subfigure 1
\hspace*{\fill}%          % empty line absolutely necessary!

\vspace*{8pt}%

\hspace*{\fill}%
\begin{subfigure}{0.56\textwidth}        % start subfigure 2
%\belowcaptionskip=8pt
\centering
\includegraphics[width=\textwidth]{example-image-b}%
\captionsetup{skip=12pt}%
\caption{Second SUB-FLOAT (\ref{fig:demoMain})}
\label{fig:demo2}
\end{subfigure}%          % end subfigure 2
\hspace*{\fill}%          % empty line absolutely necessary!

\vspace*{8pt}%

\hspace*{\fill}%
\begin{subfigure}{0.56\textwidth}     % start subfigure 3
\centering
\includegraphics[width=\textwidth]{example-image-c}%
\captionsetup{skip=12pt}%
\caption{Third SUB-FLOAT (\ref{fig:demoMain})}
\label{fig:demo3}
\end{subfigure}%              % end subfigure 3
\hspace*{\fill}%
\captionsetup{skip=8pt, format=nocap}% % required to hide the figure (main) lable!
\caption{This is a main Float}
\label{fig:demoMain}
\end{figure}
\cleardoublepage
\end{document}


Here's how the output PDF looks:

Hope you find it useful! :)

The floatrow package can do rows of figures, as well as rows of subfigures, quite easily, with its \ffigbox{figure}{caption} and \tabbox{table}{caption} commands and floatrow and subfloatrow environments. See more details inthe documentation.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{caption, floatrow}
\captionsetup{labelfont={sc, small}}
\DeclareFloatVCode{myrowsep}{\vskip 4ex}

\begin{document}

\begin{figure}[!htbp]
\floatsetup{justification =centering, rowpostcode=myrowsep}
\begin{floatrow}
\ffigbox[\FBwidth]{\includegraphics[width=0.56\textwidth]{\figa}}{\caption{First SUB-FLOAT}\label{fig:demo1}}
\end{floatrow}
\begin{floatrow}
\ffigbox[\FBwidth]{\includegraphics[width=0.66\textwidth]{\figb}}{\caption{Second SUB-FLOAT}\label{fig:demo2}}
\end{floatrow}
\begin{floatrow}
\ffigbox[\FBwidth]{\includegraphics[width=0.56\textwidth]{\figc}}{\caption{Second SUB-FLOAT}\label{fig:demo3}}
\end{floatrow}
\end{figure}

\end{document}%