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?

gmeroni
  • 431

1 Answers1

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.

Gonzalo Medina
  • 505,128
  • 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
  • I just updated my LaTeX system but even with ´subfig´ i stil have these errors. The ´subcaption´ give me these – gmeroni Mar 10 '14 at 19:57
  • @gmeroni if you're using subfig, you should not be using the subfigure environment. Take a look at Gonzalo's example in his answer. – Adam Liter Mar 10 '14 at 20:05
  • @Adam I've pasted the exacly code written by Gonzalo :) I've found in a .cls document these lines... – gmeroni Mar 10 '14 at 20:11
  • @gmeroni Please update your question with a complete minimal working example (MWE). I think that will make it easiest for us to help you. – Adam Liter Mar 10 '14 at 20:13
  • @Adam Can't because all settings and parameters are in .cls file...I just grab the ASME template from here and pasted the Gonzalo's code. In the .cls i just added those two packages... – gmeroni Mar 10 '14 at 20:17
  • Made it! Those packages need to be added to the .tex instead to the .cls – gmeroni Mar 10 '14 at 20:27
  • 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
  • There's a newer latex template for ASME conferences in CTAN, which includes a working example of subfigures: https://ctan.org/pkg/asmeconf – John Apr 22 '19 at 00:44
  • In first example you are saying that is an exsample of subcaption but you are using subfigure. What is wrong? – s.ouchene Nov 23 '19 at 16:18