[Tex/LaTex] Subfigures in a columnwide figure in a two-column document

subfloatstwo-column

I am trying to put two figures next to each other in the top of a two-column document. I found the following code on the internet and it works:

\documentclass[10pt,prl,aps,showpacs,twocolumn,unsortedaddress]{revtex4-1}
\usepackage{subfigure}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{commath}
\usepackage{graphicx,bm}
\usepackage{verbatim}

\begin{document}

\begin{figure*}[t]
\setlength{\abovecaptionskip}{17.5 pt plus 4pt minus 2pt}
\mbox{
\subfigure{\includegraphics[scale=.95]{}}\,
\subfigure{\includegraphics[scale=.95]{}}
}
\vspace{-0.6 cm}
\caption{}
\label{}
\end{figure*}

\end{document}

However, I would also like to add captions a) and b) to the two subfigures. Simply inserting \caption into the subfigure environments does not work. Does anyone know how to solve this problem?

Best Answer

subfigure is an obsolete package which shouldn't be used anynore. In its stead you can use subfig or subcaption. Below, I used the former, since subcaption will produce a warning about revtex4-1 being unsupported by caption (this might not be an issue, but I am not sure):

Notice the line

\captionsetup[subfigure]{labelformat=brace}

so the caption number will have only one parenthesis (instead of the default formatting enclosing the number inside parentheses).

\documentclass[10pt,prl,aps,showpacs,twocolumn,unsortedaddress]{revtex4-1}
\usepackage[caption=false]{subfig}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{commath}
\usepackage{graphicx,bm}
\usepackage{verbatim}

\captionsetup[subfigure]{labelformat=brace}

\begin{document}

\begin{figure*}
\subfloat[text for the first subfigure\label{sfig:testa}]{%
  \includegraphics[height=3cm,width=.49\linewidth]{example-image-a}%
}\hfill
\subfloat[text for the second subfigure\label{sfig:testa}]{%
  \includegraphics[height=3cm,width=.49\linewidth]{example-image-b}%
}
\caption{}
\label{}
\end{figure*}

\end{document}

enter image description here

With subcaption, the code would be:

\documentclass[10pt,prl,aps,showpacs,twocolumn,unsortedaddress]{revtex4-1}
\usepackage{subcaption}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{commath}
\usepackage{graphicx,bm}
\usepackage{verbatim}

\captionsetup[subfigure]{labelformat=brace}

\begin{document}

\begin{figure*}
\begin{subfigure}{0.49\linewidth}
\centering
\includegraphics[height=3cm,width=\linewidth]{example-image-a}
\caption{text for the first subfigure}
\label{sfig:testa}
\end{subfigure}\hfill
\begin{subfigure}{0.49\linewidth}
\centering
\includegraphics[height=3cm,width=\linewidth]{example-image-b}
\caption{test for the second subfigure}
\label{sfig:testb}
\end{subfigure}\hfill
\caption{}
\label{}
\end{figure*}

\end{document}

But, as I mentioned before, you'll receive a warning:

Package caption Warning: Unsupported document class (or package) detected, usage of the caption package is not recommended.See the caption package documentation for explanation.