5

I am writing a manuscript and I am using the subfloat package to include in a figure several figures, if I don't include a caption it compiles nicely, but when including the caption I get the error

! Improper \prevdepth.

I have tried using the caption package too but doesn't seem to work.
What I have looks like:

\documentclass[aps,preprint,pra]{revtex4-1}
\usepackage{natbib}
\usepackage{graphicx} 
\usepackage{subfig}

\begin{document}

\begin{figure}
\centering
\subfloat{
\begin{tabular}{cc}
\hline \hline
First Column & Second column \\[1ex]
\hline

 \includegraphics[width=0.45\textwidth]{figure1} &\includegraphics[width=0.45\textwidth]{figure2} \\[0.5ex]

\hline \hline
\end{tabular}
}\caption{Caption for figures 1 and 2}\label{fig1and2}
\end{figure}

\end{document}

If someone can comment on this I will really appreciate it. Thanks,

  • Your code compiles without problems on my TeXLive 2014 installation – user31729 Apr 6 '15 at 19:27
  • Remember to do \usepackage[caption=false]{subfig} with revtex4-1 – egreg Apr 6 '15 at 20:33
  • @egreg Thank you so much!! that does the trick, now it is working perfectly. – jealopez Apr 6 '15 at 20:41
4

Always call

\usepackage[caption=false]{subfig}

with the revtex4-1 document class, which is not compatible with caption. The option is indeed meant not to load the caption package along with subfig (it will emulate the needed features).

Note that it's better avoiding blank lines inside \subfloat (not required, though). More importantly, you're missing some % and getting unwanted spaces:

\subfloat{% <----------- important
  \begin{tabular}{cc}
  ...
  \end{tabular}% <------ important
}
\caption{...}\label{...}

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.