[Tex/LaTex] \subfigure errors with ASME template

subfloatssublime-text

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?

Best Answer

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.