4

I am having some troubles in using \subfigure in LaTeX template for ASME conference papers, version 1.7. Here's my code:

Figure

% GRAPHICS
\RequirePackage{caption}
\RequirePackage{subcaption}
\usepackage{graphicx}
\usepackage{subfigure}   

 \begin{figure}[t]
    \begin{center}
    \subfigure[Main Effect Plot]{
        \includegraphics[width=\columnwidth,keepaspectratio]{Figure/Main_Effects_Plot.pdf}
        \label{fig:main_eff_plot}}
    \subfigure[Interaction Plot]{
        \includegraphics[width=\columnwidth,keepaspectratio]{Figure/Interaction_Plot.pdf}
        \label{fig:inter_plot}}
    \end{center}
    \caption{FACTORIAL PLOT}
    \end{figure}

Errors in LaTeX source

/usr/local/texlive/2013/texmf-dist/tex/latex/subfigure/subfigure.sty:113: LaTeX Error: No counter 'figure' defined. [\newcounter{subfigure}[figure]]
/usr/local/texlive/2013/texmf-dist/tex/latex/subfigure/subfigure.sty:126: LaTeX Error: No counter 'table' defined. [\newcounter{subtable}[table]]
/usr/local/texlive/2013/texmf-dist/tex/latex/subfigure/subfigure.sty:413: LaTeX Error: Command \subref already defined. [  \ref{sub@#1}}]
./asme2e.tex:360: Undefined control sequence. [\begin{quotation}]
./asme2e.tex:360: Undefined control sequence. [\begin{quotation}]

Any help?

  • Don't use \RequirePackage, just use \usepackage (see Why does the LaTeX kernel define \usepackage and \RequirePackage?). Also, all of these should be before \begin{document}, in what is called the preamble to the document. And, finally, only use subcaption, don't also use subfigure (see subcaption vs. subfig: Best package for referencing a subfigure). – Adam Liter Mar 10 '14 at 15:28
  • Using just \usepackage{captino}, \usepackage{subcaption} and \usepackage{graphics} in the preamble give me these errors: ./asme2e.tex:258: Undefined control sequence. [\subfigure]` ./asme2e.tex:261: Undefined control sequence. [\subfigure] – gmeroni Mar 10 '14 at 15:33
  • That's because subfigure is defined as an environment in the subcaption package---i.e., you use \begin{subfigure} and \end{subfigure} instead of \subfigure{}. You can take a look at the subcaption documentation or just see @Gonzalo's answer. – Adam Liter Mar 10 '14 at 15:36
  • @Adam Done but the outcome doesn't change :( – gmeroni Mar 10 '14 at 20:03
6

subfigure is an obsolete package which shouldn't be used anymore; you can use subfig or subcaption instead.

An example with subcaption:

\documentclass{asme2e}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}{\columnwidth}
\includegraphics[width=\columnwidth,keepaspectratio]{Figure/Main_Effects_Plot.pdf}
\caption{Main Effect Plot}
\label{fig:main_eff_plot}
\end{subfigure}\hfill
\begin{subfigure}{\columnwidth}
\includegraphics[width=\columnwidth,keepaspectratio]{Figure/Interaction_Plot.pdf}
\caption{Interaction Plot}
\label{fig:inter_plot}
\end{subfigure}
\caption{FACTORIAL PLOT}
\end{figure}

\end{document} 

enter image description here

An example with subfig:

\documentclass{asme2e}
\usepackage[caption=false]{subfig}
\usepackage[demo]{graphicx}

\begin{document}

 \begin{figure}[t]
\centering
\subfloat[Main Effect Plot\label{fig:main_eff_plot}]{%
  \includegraphics[width=\columnwidth,keepaspectratio]{Figure/Main_Effects_Plot.pdf}
}\hfill
\subfloat[Interaction Plot\label{fig:inter_plot}]{%
  \includegraphics[width=\columnwidth,keepaspectratio]{Figure/Interaction_Plot.pdf}
}%
\caption{FACTORIAL PLOT}
\end{figure}

\end{document} 

Notice that loading captionor subcaption with your class will issue a warning:

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

which indicates that using the caption package might not be convenient. In this case, if you want to be sure that caption won't produce any interference with the way asme2e handles captions, you can use subfig with the caption=false option as in my last example.

  • Your first example give many erros: ./asme2e.tex:270: LaTeX Error: Environment subfigure undefined. [\begin{subfigure}] ./asme2e.tex:270: Missing number, treated as zero. [\begin{subfigure}{\columnwidth}] ./asme2e.tex:270: Illegal unit of measure (pt inserted). [\begin{subfigure}{\columnwidth}] ./asme2e.tex:274: LaTeX Error: \begin{figure} on input line 268 ended by \end{subfigure}. [\end{subfigure}] ./asme2e.tex:275: LaTeX Error: Environment subfigure undefined. [\begin{subfigure}] – gmeroni Mar 10 '14 at 15:41
  • 2
    @gmeroni Update you LaTeX system. – Gonzalo Medina Mar 10 '14 at 15:41
  • and:./asme2e.tex:275: Missing number, treated as zero. [\begin{subfigure}{\columnwidth}] ./asme2e.tex:275: Illegal unit of measure (pt inserted). [\begin{subfigure}{\columnwidth}] ./asme2e.tex:279: LaTeX Error: \begin{figure} on input line 268 ended by \end{subfigure}. [\end{subfigure}] – gmeroni Mar 10 '14 at 15:41
  • @gmeroni In any case, as I mentioned in my last edit, with classes not supported by the caption package, you can always use subfig, as in the second code. – Gonzalo Medina Mar 10 '14 at 15:42
  • 1
    For future reference, you can construct a MWE in this case. All you need to do is make a minimal .tex file that exhibits your problem and then link us to the .cls file. Glad you figured it out. – Adam Liter Mar 10 '14 at 20:46

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.