[Tex/LaTex] AIP conference proceedings template – placing subfigures vertically

documentclass-writingsubfloats

I am using the AIP conference proceedings class file (aip-cp.cls) for writing a paper. I want to place two subfigures vertically, one below the other, using the subcaption package. The following is a code similar to what I had used :

\documentclass{aip-cp}
\usepackage{graphicx}
\usepackage{subcaption}
\graphicspath{{./Figures/}}

\begin{document}
\title{Test}

\begin{figure}
\captionsetup{type=figure}
    \begin{subfigure}[b]{0.5\textwidth}
        \includegraphics[width=\textwidth]{ScatteringAmplitude.png}
    \end{subfigure}\\
    \begin{subfigure}[b]{0.5\textwidth}
        \includegraphics[width=\textwidth]{ScatteringAmplitude.png}
    \end{subfigure} 
\end{figure}

\end{document}

I used \captionsetup in the above code because aip-cp class defines its own figure environment, and therefore the subcaption package does not recognize the figure as a floating environment as explained in an answer to this question.

The problem is that the two subfigures appear side by side despite of using \\ or \newline. I do not face this problem when I use the article class however. I believe that the problem is in the aip-cp class, but as I am new to latex I don't know if it is possible to edit it to solve my problem.

The aip-cp class can be downloaded from here. I would appreciate if someone can go through the aip class file and let me know how to edit it. I am also happy with any alternate solution.

PS: I have also tried to use \subfloat from the subfig package, but the output was still the same.

Best Answer

The class is definitely not compatible with caption (and so also subcaption). It also redefines the figure environment in such a way that fools \subfloat from subfig into thinking that it is not in a floating environment.

Here's a suggestion for making subfig work, but I'd not be surprised if the copy editor of your submission will not be happy with it.

\documentclass{aip-cp}
\usepackage{graphicx}
\usepackage[caption=false]{subfig}
\graphicspath{{./Figures/}}

\makeatletter
\newenvironment{subfigures}
 {\begin{minipage}{\columnwidth}\def\@captype{figure}\centering}
 {\end{minipage}}
\makeatother

\begin{document}
\title{Test}

\begin{figure}

\begin{subfigures}
\subfloat[]{\includegraphics[width=0.5\textwidth]{example-image-a}}

\subfloat[]{\includegraphics[width=0.5\textwidth]{example-image-b}}
\end{subfigures}

\caption{This is the caption}

\end{figure}

\end{document}

enter image description here