No final de 2016, a ACM publicou seuModelo de artigo mestre ACM 2017. Esta classe de documento quebra muitos códigos LaTeX que alguém poderia ter escrito usando classes de documentos anteriores do ACM, especificamente a sig-alternate
classe.
Especificamente, tenho tido problemas para legendar tabelas e usar subfiguras (legendadas ou não) com a nova classe. OGuia do usuárionão diz nada sobre isso, especificamente na Seção 2.5, que trata de figuras e tabelas.
Em vez de perguntar sobre algo específico que não funcionou para mim, o que eu gostaria de saber é a abordagem comum e idiomática, se preferir, para esse problema:
- Quais combinações de pacotes usar com a classe (
subfigure
,subcaption
,subfig
,floatrow
etc.)? - Existe alguma inicialização especial,
\patchcmd
ing ou outro encantamento vodu que devo incluir em meu preâmbulo? - Existem layouts de figuras/subfiguras específicos que devo evitar ou ter cuidado? O mesmo vale para legendas.
Responder1
Apenas para expandir a resposta de Boris, veja como você pode (e deve) fazer isso subcaption
. Em vez de \autoref
acredito que seja melhor usar \cref
from \cleveref
.
\documentclass[sigconf]{acmart}
%---------------------------------------------------------------
% 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
\newcommand{\graphicsplaceholder}[2]{%
\begin{tcolorbox}[valign=center,width=#1,height=#2,arc=0.5mm,auto outer arc]%
\centering \sf missing graphic%
\end{tcolorbox}%
}
%---------------------------------------------------------------
\usepackage{subcaption}
\usepackage{cleveref}
\crefname{figure}{Figure}{Figures}
\begin{document}
\title{Tables, figures and subfigures \texorpdfstring{\\}{}
with the new ACM 2017 article template}
\author{Nobody in particular}
\affiliation{\institution{University of Life}}
\email{[email protected]}
\maketitle
\begin{abstract}
The quick brown fox jumps over the lazy dog.
\end{abstract}
\section{Figures}
Let's start with a simple figure, single-column, no subfigures --- using a
\texttt{figure} environment. That will be \cref{figure-with-no-subfigs}.
\begin{figure}[htpb]
\centering
% 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:
\graphicsplaceholder{8cm}{1cm}
\caption{This is a figure with no subfigures}
\label{figure-with-no-subfigs}
\end{figure}
\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}.
\begin{figure}[htpb]
\centering
\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:
\graphicsplaceholder{4cm}{1cm}%
}
\subcaptionbox{Another subfigure\label{second-subfig}}{%
\graphicsplaceholder{4cm}{1cm}%
}
\caption{A caption for the single-column figure with two subfigures}
\label{first-figure-with-subfigures}
\end{figure}
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}.
\begin{figure*}[htpb]
\centering
\subcaptionbox{Yet another caption\label{third-subfig}}{%
\graphicsplaceholder{8cm}{1cm}%
}
\subcaptionbox{This is getting old\label{fourth-subfig}}{%
\graphicsplaceholder{8cm}{1cm}%
}
\caption{A caption for the two-column figure (also with two subfigures)}
\label{a-two-column-figure}
\end{figure*}
\section{Tables}
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{table}[thpb]
\begin{tabular}{ c c c }
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
\end{tabular}
\caption{This is a caption for a \texttt{table} float, with a
\texttt{tabular} environment inside it}
\label{first-table}
\end{table}
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.
\end{document}
Responder2
A seção 2.12 do guia do usuário recomenda subcaption
o pacote "para figuras complexas com vários subtramas ou subfiguras que requerem sublegendas separadas".
Responder3
Ok, o seguinte funciona. Agradecemos o feedback nos comentários em relação à escolha dos pacotes ou qualquer outra coisa.
\documentclass[sigconf]{acmart}
%---------------------------------------------------------------
% 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
\newcommand{\graphicsplaceholder}[2]{%
\begin{tcolorbox}[valign=center,width=#1,height=#2,arc=0.5mm,auto outer arc]%
\centering%
\sf missing graphic%
\end{tcolorbox}%
}
%---------------------------------------------------------------
\usepackage{float}
\usepackage{subfig}
\begin{document}
\title{Tables, figures and subfigures \\ with the new ACM 2017 article template}
\author{Nobody in particular}
\affiliation{ \institution{University of Life} }
\email{[email protected]}
\maketitle
\begin{abstract}
The quick brown fox jumps over the lazy dog.
\end{abstract}
\section{Figures}
Let's start with a simple figure, single-column, no subfigures --- using a
\texttt{figure} environment. That will be \autoref{figure-with-no-subfigs}.
\begin{figure}[htpb]
\centering
% 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:
\graphicsplaceholder{8cm}{1cm}
\caption{This is a figure with no subfigures}
\label{figure-with-no-subfigs}
\end{figure}
\subsection{Figures with subfigures}
Le'ts add a figure with two subfigures; the subfigures will be added using
\verb|\subfloat[caption goes here]|, so they should also be captioned.
That will be \autoref{first-figure-with-subfigures}.
\begin{figure}[htpb]
\centering
\subfloat[Some subfigure]{
\graphicsplaceholder{4cm}{1cm}
\label{first-subfig}
}
\subfloat[Another subfigure]{
\graphicsplaceholder{4cm}{1cm}
\label{second-subfig}
}
\caption{A caption for the single-column figure with two subfigures}
\label{first-figure-with-subfigures}
\end{figure}
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
\autoref{a-two-column-figure}.
\begin{figure*}[htpb]
\centering
\subfloat[Yet another caption]{
\graphicsplaceholder{8cm}{1cm}
\label{third-subfig}
}
\subfloat[This is getting old]{
\graphicsplaceholder{8cm}{1cm}
\label{fourth-subfig}
}
\caption{A caption for the two-column figure (also with two subfigures)}
\label{a-two-column-figure}
\end{figure*}
\section{Tables}
Let's add a \texttt{table} environment, with a caption near the end of it (after
the \texttt{tabular} environment). That will be \autoref{first-table}.
\begin{table}[thpb]
\begin{tabular}{ c c c }
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
\end{tabular}
\caption{This is a caption for a \texttt{table} float, with a \texttt{tabular}
environment inside it}
\label{first-table}
\end{table}
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.
\end{document}
E quando compilo isso com o TeXLive 2015.20160320-1 (a versão fornecida pela distribuição no Linux Mint 18.1), recebo duas páginas:
Notas:
- A razão pela qual não uso
subcaption
é que, bem, isso é próximo do que eu estava usando com classes ACM mais antigas, e optei por alterações mínimas para fazer as coisas funcionarem (mas fique à vontade para criticar). - Não sei por que recebo o bloco começando com "Formato de referência ACM". Eles fazem isso de propósito? É muito difícil para os olhos e irritante.
- Não tenho certeza de como balancear as colunas agora (mas este exemplo não é sobre balanceamento de colunas).
- Não há numeração de páginas - provavelmente porque essas coisas estão dentro dos PDFs dos procedimentos, que têm seus números constantes em muitos artigos.
- Não sei bem por que o
figure*
ambiente limpa a página. O texto não deveria apenas preencher as duas colunas anteriores, com a figura vindo depois? Hum.