2016年底,ACM發布了2017 ACM Master 文章模板。此文檔類別破壞了許多可能使用早期 ACM 文檔類別(特別是 類別)編寫的 LaTeX 程式碼sig-alternate
。
具體來說,我在新類別中為表格添加標題和使用子圖(帶標題或其他方式)時遇到了麻煩。這使用者手冊對此沒有提及,特別是在第 2.5 節中,涉及圖形和表格。
我不想問一些對我不起作用的具體問題,而是想知道解決這個問題的常見、慣用的方法:
- 哪些套件組合與類別(
subfigure
、subcaption
、subfig
等floatrow
)一起使用? \patchcmd
我應該在序言中包含一些特殊的初始化、ing 或其他巫術咒語嗎?- 是否有我應該避免或小心的特定圖形/子圖佈局?字幕也是如此。
答案1
只是為了擴展鮑里斯的答案,以下是您可以(並且應該)如何使用subcaption
.我\autoref
相信最好使用\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}
答案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 的會議記錄中,許多文章都有自己的編號。
- 我不太清楚為什麼
figure*
環境會清除頁面。文字不應該只填滿前面的兩列,然後是數字嗎?唔。