[Tex/LaTex] How to format/include subfigures in AASTex document class

aastexsubfloats

I've been writing a document using the basic "article" class, but now I need to change it to "aastex." When I do this, my subfigures do not work. Is there any way aastex allows subfigures?

I tried to keep my original document as bare-bones as possible, so I'm pretty sure caption and subcaption were the only packages I included for this.

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
        \centering
        \begin{subfigure}[b]{0.45\textwidth}
                \centering
                \includegraphics[width=\textwidth]{fig1.pdf}
                \caption{Caption 1}
                \label{fig:fig1}
        \end{subfigure}%
        \quad
        \begin{subfigure}[b]{0.45\textwidth}
                \centering
                \includegraphics[width=\textwidth]{fig2.pdf}
                \caption{Caption 2}
                \label{fig:fig2}
        \end{subfigure}
        \caption{Side-by-side figures.}
        \label{fig:figures}
\end{figure}

Best Answer

First of all, let's see what a regular figure looks like under aastex:

enter image description here

\documentclass{aastex}
\usepackage{graphicx,showframe}

\begin{document}

\begin{figure}
  \centering
  \includegraphics[width=.3\linewidth]{example-image}
  \figcaption{Side-by-side figures.}
  \label{fig:figures}
\end{figure}

\end{document}

Note the use of \figcaption for the caption of a figure. The document class sets the caption flush left (fully justified). Now, let's look at using caption and/or subcaption:

enter image description here

\documentclass{aastex}
\let\captionbox\relax
\usepackage{graphicx,caption,subcaption,showframe}
\captionsetup[figure]{labelsep=space,singlelinecheck=false}
\captionsetup[subfigure]{justification=centering}

\begin{document}

\begin{figure}
  \centering
  \begin{subfigure}[b]{0.45\textwidth}
    \centering
    \includegraphics[width=.6\linewidth]{example-image-a}
    \caption{Caption 1}
    \label{fig:fig1}
  \end{subfigure}%
  \quad
  \begin{subfigure}[b]{0.45\textwidth}
    \centering
    \includegraphics[width=.4\linewidth]{example-image-b}
    \caption{Caption 2}
    \label{fig:fig2}
  \end{subfigure}
  \caption{Side-by-side figures.}
  \label{fig:figures}
\end{figure}

\end{document}

Letting \captionbox to \relax makes caption work with aastex (so it's a requirement). Then, we set the [figure] options to ignore a singlelinecheck - this sets the figure to be as wide as \linewidth regardless of the caption width. Also, a space is added as labelsep. We also reset the justification to \centering for [subfigures], as they inherit whatever is specified for [figure].

Of course, one can also fake it using tabulars (losing some of the cross-referencing functionality):

enter image description here

\documentclass{aastex}
\usepackage{graphicx,showframe}

\begin{document}

\begin{figure}
  \centering
  \begin{tabular}[b]{@{}p{0.45\textwidth}@{}}
    \centering\includegraphics[width=.6\linewidth]{example-image-a} \\
    \centering\small (a) Caption 1
  \end{tabular}%
  \quad
  \begin{tabular}[b]{@{}p{0.45\textwidth}@{}}
    \centering\includegraphics[width=.4\linewidth]{example-image-b} \\
    \centering\small (b) Caption 2
  \end{tabular}
  \caption{Side-by-side figures.}
  \label{fig:figures}
\end{figure}

\end{document}