[Tex/LaTex] Idiomatic approach to captioned subfigures and tables with the 2017 acmart class


In late 2016, the ACM published its 2017 ACM Master Article Template. This document class breaks a lot of LaTeX code one might have written using earlier ACM document classes, specifically the sig-alternate class.

Specifically, I've been having trouble captioning tables, and using subfigures (captioned or otherwise), with the new class. The user's guide says nothing about this, specifically not in Section 2.5, dealing with figures and tables.

Instead of asking about something specific which did not work for me, what I'd like to know is the common, idiomatic if you will, approach to this issue:

  • Which combination(s) of packages to use with the class (subfigure, subcaption, subfig, floatrow etc.)?
  • Is there some special initialization, \patchcmding or other voodoo incantation I should include in my preamble?
  • Are there specific figure/subfigure layouts I should avoid, or be careful about? Ditto w.r.t. captioning.

Best Answer

Just to expand Boris’ answer, here's how you can (and should) do with subcaption. Instead of \autoref I believe it's better to use \cref from \cleveref.


% You don't need this block of lines in your article - I do
% need, them since I use placeholders instead of actual graphics
\usepackage{tcolorbox} % for graphics placeholders
  \begin{tcolorbox}[valign=center,width=#1,height=#2,arc=0.5mm,auto outer arc]%
    \centering \sf missing graphic%




\title{Tables, figures and subfigures \texorpdfstring{\\}{}
   with the new ACM 2017 article template}
\author{Nobody in particular}
\affiliation{\institution{University of Life}}

The quick brown fox jumps over the lazy dog.


Let's start with a simple figure, single-column, no subfigures --- using a
\texttt{figure} environment. That will be \cref{figure-with-no-subfigs}.

  % What you would typically have here is something like:
  % \includegraphics[width=\columnwidth]{some-file.pdf}
  % but for this example, let's go with a placeholder instead:
  \caption{This is a figure with no subfigures}

\subsection{Figures with subfigures}

Let's add a figure with two subfigures; the subfigures will be added with
\verb|\subcaptionbox{caption goes here}|, so they should also be captioned. 
That will be \cref{first-figure-with-subfigures}.

  \subcaptionbox{Some subfigure\label{first-subfig}}{%
    % What you would typically have here is something like:
    % \includegraphics[width=0.2\textwidth]{some-file.pdf}
    % but for this example, let's go with a placeholder instead:
  \subcaptionbox{Another subfigure\label{second-subfig}}{%
  \caption{A caption for the single-column figure with two subfigures}

Let's conclude this section by repeating the same figure, but now as a 
two-column figure, i.e. using the \verb|{figure*}| environment. That will 
be \cref{a-two-column-figure}, with \cref{first-subfig} and \cref{second-subfig}.

  \subcaptionbox{Yet another caption\label{third-subfig}}{%
  \subcaptionbox{This is getting old\label{fourth-subfig}}{%
  \caption{A caption for the two-column figure (also with two subfigures)}


Let's add a \texttt{table} environment, with a caption near the end of it
(after the \texttt{tabular} environment). That will be \cref{first-table}.

\begin{tabular}{ c c c }
  1 & 2 & 3 \\
  4 & 5 & 6 \\
  7 & 8 & 9 \\
\caption{This is a caption for a \texttt{table} float, with a 
  \texttt{tabular} environment inside it}

And we're all done, except for one last thing...:

\paragraph{Warning} Don't ever define a \verb|\tblname| command. This was 
possible with older ACM document class (e.g. \texttt{sig-alternate} v2.8), 
but now it will trigger errors when you try to caption your floats.


enter image description here

Related Question