10

Hi am using the following code to place two figures side by side:

\usepackage{subfig}
\usepackage{graphicx}

%other part of code which compiles fine

\begin{figure}
     \centering
     \subfloat[][a]{\includegraphics{<figure1>}\label{<figure1>}}
     \subfloat[][b]{\includegraphics{<figure2>}\label{<figure2>}}
     \caption{Comparison of steady state results (a) x method (b) y method}
     \label{steady_state}
\end{figure}

%remaining part

this gives me an error: \subfloat outside float.

what would be incorrect in this ??

1
18

Please always post a complete document that shows the error. If I make a document from your posted fragments then I get no error, so presumably your error is in a part of your document you have not shown.

enter image description here

\documentclass{article}

\usepackage{subfig}
\usepackage[demo]{graphicx}

\begin{document}
other part of code which compiles fine

\begin{figure}
     \centering
     \subfloat[][a]{\includegraphics{<figure1>}\label{<figure1>}}
     \subfloat[][b]{\includegraphics{<figure2>}\label{<figure2>}}
     \caption{Comparison of steady state results (a) x method (b) y method}
     \label{steady_state}
\end{figure}
%remaining part

\end{document}

If you can reproduce the error please edit your question to include a document that shows the problem.

5
  • 1
    i am actually using a special documentclass called 'aipproc'. This is prescribed for any publication by the American Institute of Physics, available at cec-icmc.org/author-information/publication/forms . I am very new to LaTex typsetting and so wasn't unsure where the problem could be. Is there a way to find out if some settings in the 'aipproc' class prohibits placing figures side by side ? Thanks David :) – nole May 9 '13 at 3:29
  • i am actually using a special documentclass called 'aipproc'. This is prescribed for any publication under the American Institute of Physics banner, and is available at cec-icmc.org/author-information/publication/forms . I am very new to LaTex typsetting and so was unsure where the problem could be. Is there a way to find out if some settings in the 'aipproc' class prohibits placing figures side by side ? Thanks David :) – nole May 9 '13 at 3:32
  • sorry no time to download that now but if subfgloat doesn;t work you can always put the images side by side under a single caption just \includegraphics{...}\hspace{10pt}\includegraphics{....} \caption{...} – David Carlisle May 9 '13 at 8:28
  • Where would you put the source reference in case of using subfloat images: One single source below each image or just one source into the main caption? – Dave Feb 3 '19 at 8:13
  • @Dave that's a design question not a tex one, just do whatever is the convention in your field or the journal you are publishing in. – David Carlisle Feb 3 '19 at 9:12
3

You mention you are using the aipproc document class... the more recent version of this is aip-cp.

The aip-cp document class - for AIP Conference Proceedings - doesn't support using \subfloat. Moreover, it's best to avoid using additional packages for conference proceedings or journal submissions when you don't have to. Especially with subfigures when you can place them in other structures without problem.

Below I've placed each subfigure inside a tabular that is aligned at the [b]aseline using the following default layout per subfigure:

\begin{tabular}[b]{c}
  <subfigure image> \\
  \small <subfigure caption>
\end{tabular}

enter image description here

\documentclass{aip-cp}% http://scitation.aip.org/content/aip/proceeding/aipcp/info/authors

\usepackage{graphicx}

\begin{document}

Some text here.

\begin{figure}
  \centering
  \begin{tabular}[b]{c}
    \includegraphics[width=.3\linewidth]{example-image-a} \\
    \small (a)
  \end{tabular} \qquad
  \begin{tabular}[b]{c}
    \includegraphics[width=.25\linewidth]{example-image-b} \\
    \small (b)
  \end{tabular}
  \caption{Comparison of steady state results (a)~x method (b)~y method}
\end{figure}

Some more text here.

\end{document}
-2

Use this structure. You must use these packages

\usepackage{subfig}
\usepackage{graphicx}

\begin{figure}
\centering
  % Requires \usepackage{graphicx}
  \subfloat[caption fig (a).]{\includegraphics[width=7cm]{<fig1>}\label{fig1}}
  \hspace{0.5cm}
  \subfloat[caption fig b.]{\includegraphics[width=7cm]{<fig2>}\label{fig2}}
  \vspace{0.5cm}
   \caption{caption fig.}\label{fig:}
\end{figure}
1
  • Welcome to TeX.SE. You actually repeated OP question and not solve his/her problem. – Zarko Sep 20 '16 at 19:45

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.