2016 年末,ACM 发布了2017 ACM 主条目模板。此文档类破坏了使用早期 ACM 文档类(特别是该类)编写的大量 LaTeX 代码sig-alternate
。
具体来说,我在用新类给表格添加标题和使用子图(带标题或其他)时遇到了麻烦。用户手册对此只字未提,特别是第 2.5 节中有关图表的部分。
我不想询问一些对我没有用的具体方法,而是想知道解决这个问题的常见的、惯用的方法:
- 哪些包组合可与该类一起使用(、、
subfigure
等)?subcaption
subfig
floatrow
\patchcmd
我是否应该在序言中包含一些特殊的初始化、或其他巫术咒语?- 有哪些特定的图形/子图形布局我应该避免或小心?同上,字幕也是如此。
答案1
只是为了扩展鲍里斯的回答,以下是你可以(也应该)使用 的方法subcaption
。\autoref
我认为最好使用\cref
而不是\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}
答案2
用户指南的第 2.12 节推荐subcaption
使用“针对具有多个子图或需要单独子字幕的子图的复杂图形”的包。
答案3
好的,以下操作有效。欢迎在评论中就软件包选择或其他内容提供反馈。
\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}
当我使用 TeXLive 2015.20160320-1(Linux Mint 18.1 上发行版提供的版本)编译它时,我得到了两个页面:
笔记:
- 我不使用的原因
subcaption
是,这与我使用旧的 ACM 课程时使用的非常接近,并且我选择进行最少的更改来使其正常运行(但请随意批评)。 - 我不知道为什么会出现以“ACM 参考格式”开头的区块。他们是故意这样做的吗?这真的很伤眼,也很烦人。
- 我现在不确定如何平衡列(但这个例子与列平衡无关)。
- 没有页码——可能是因为这些内容放在会议论文集 PDF 中,而这些 PDF 在许多文章中都有连续编号。
- 我不太清楚
figure*
环境为什么要清除页面。难道文本不应该填满它前面的两列,图形则放在后面吗?嗯。