4

I'm trying to put a figure with subfigures, using the acmsmall class. When compiling I get the following error:

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

) (/usr/local/texlive/2012/texmf-dist/tex/latex/caption/subcaption.sty

! LaTeX Error: Command \subcaption already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation. 
Type  H <return>  for immediate help.  ...                                    

l.57      \caption@gobble}}
                           % 
?

When I just skip it, another error appears.

Package caption Warning: \caption will not be redefined since it's already
(caption)                redefined by a document class or package which is
(caption)                unknown to the caption package.
See the caption package documentation for explanation.


! Package caption Error: The `subcaption' package does not work correctly
(caption)                in compatibility mode.

See the caption package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.7 \begin{document}

? 

If I continue, I get the figure fine, but I would like to know what is happening. I never had problems inserting subfigures with other document classes (e.g. IEEEtran).

Here's a MWE:

\documentclass[prodmode,acmtecs]{acmsmall}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
 \begin{subfigure}[b]{0.5\textwidth}
                \includegraphics{acmsmall-mouse.pdf}
                \caption{A subfigure}
        \end{subfigure}%
  \begin{subfigure}[b]{0.5\textwidth}
                \includegraphics{acmsmall-mouse.pdf}
                \caption{Another subfigure}
        \end{subfigure}%
\caption{Several figures}
\end{figure}

\end{document}

Is there a preferred way to create subfigures with acmsmall?

1
  • 1
    Welcome to TeX.SX! The packages work by redefining commands defined by the documentclass. If it is a documentclass the package writer doesn't know then caption will not make the redefinition and you can not expect the package to work. You should probably use a different method compatible with the class. Incidentally, usually only the first error message is meaningful. Commented Feb 20, 2015 at 9:47

4 Answers 4

4

acsmall.cls and used images downloaded here: http://www.acm.org/publications/latex_style/v2-acmsmall.zip


The acmsmall class defines a \subcaption command, so you can use minipages instead of subfigures for your purpose.

MWE:

\documentclass[prodmode,acmtecs]{acmsmall}

\usepackage{graphicx}

\begin{document}

\begin{figure}
\begin{minipage}[b]{0.5\textwidth}
\includegraphics{acmsmall-mouse.pdf}\\
\subcaption{A subfigure}
\end{minipage}%
\begin{minipage}[b]{0.5\textwidth}
\includegraphics{acmsmall-mouse.pdf}\\
\subcaption{Another subfigure}
\end{minipage}%
\caption{Several figures}
\end{figure}

\end{document} 

Output:

enter image description here

3
  • Thx, that worked perfectly!
    – cygnusv
    Commented Feb 20, 2015 at 10:21
  • 1
    It seems you downloaded lot of mice! ;)
    – user11232
    Commented Feb 21, 2015 at 0:15
  • @HarishKumar Yes, I've missed the cat... Commented Feb 21, 2015 at 6:20
4

The class acmsmall is defining a command \subcaption which results in the captions shown in Karl's answer. If you are not strictly bound to that template and want to use normal labelling as from the package subcaption, you will have to undefine that very command. The reason for doing so could be that you would like to reference to some subfigure (\ref{fig:a}) as has been asked here.

This could look like the following:

% arara: pdflatex

\documentclass[prodmode,acmtecs]{acmsmall}
\let\subcaption\relax
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{hyperref}

\begin{document}    
    \begin{figure}
        \begin{subfigure}[b]{0.49\textwidth}
            \includegraphics{acmsmall-mouse.pdf}
            \subcaption{A subfigure}\label{fig:a}
        \end{subfigure}
        \begin{subfigure}[b]{0.49\textwidth}
            \includegraphics{acmsmall-mouse.pdf}
            \subcaption{Another subfigure}\label{fig:b}
        \end{subfigure}
        \caption{Several figures}\label{fig:1}
    \end{figure}    
\end{document}

enter image description here


Please note, that this is not in the idea of the editor which provided that template. Before tweaking around like this, you should talk to the same. Maybe, numbered subcaptions do not fit the overall design. In this case, you will have to reference like as you can see in Figure~\ref{fig:1} (left pic.)

2
  • Thanks. Essentially what you are proposing is using \let\subcaption\relax for deleting the definition from acmsmall and then using the regular subcaption package, right?
    – cygnusv
    Commented Jun 9, 2015 at 10:08
  • @cygnusv Absolutely. I do not have this class here. I would be happy if you test my code, correct it, if necessary, and add a screen shot to my answer. Thank you.
    – LaRiFaRi
    Commented Jun 9, 2015 at 10:09
1

Ok, it seems I cannot comment the answer from LaRiFaRi so here I write ... The answer from LaRiFaRi is not working as is. I don't know why but I only managed to make it work by adding the hyperref package. Here is the code:

\documentclass[prodmode,acmtecs]{acmsmall}
\let\subcaption\relax
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{hyperref} %WHY is that ?


\begin{document}

\begin{figure}
    \begin{subfigure}[b]{0.49\textwidth}
        \includegraphics{acmsmall-mouse.pdf}
        \subcaption{A subfigure}\label{fig:a}
    \end{subfigure}
    \begin{subfigure}[b]{0.49\textwidth}
        \includegraphics{acmsmall-mouse.pdf}
        \subcaption{Another subfigure}\label{fig:b}
    \end{subfigure}
    \caption{Several figures}\label{fig:1}
\end{figure} 
\end{document}

And the resulting image: result

1

It so turns out that including hyperref has one more effect: I can use

\begin{minipage}
...
\subcaption{...} 
...
\end{minipage}

Without having to use the subfigure environment anywhere, explicitly.

1
  • 2
    Welcome to TeX.SE! Your answer is, at it stands, is a bit terse, and its connection to the original posting may not be clear immediately. It would be helpful if you fleshed out your claim that loading the hyperref package and defining minipage enviroments somehow makes it unnecessary to work with subfigure environments. (Hint: The subfigure environment may be a specialized minipage environment.)
    – Mico
    Commented Jul 22, 2015 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .