
我正在嘗試使用類別來放置帶有子圖的圖形acmsmall
。編譯時我收到以下錯誤:
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}}
%
?
當我跳過它時,會出現另一個錯誤。
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}
?
如果我繼續,我會得到很好的數字,但我想知道發生了什麼。我在插入其他文檔類別(例如 IEEEtran)的子圖時從來沒有遇到過問題。
這是一個 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}
是否有建立子圖的首選方法acmsmall
?
答案1
acsmall.cls
並使用在這裡下載的圖片:http://www.acm.org/publications/latex_style/v2-acmsmall.zip
該類別acmsmall
定義了一個\subcaption
命令,因此您可以使用minipage
s 而不是subfigure
s 來達到您的目的。
微量元素:
\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}
輸出:
答案2
該類別acmsmall
正在定義一個命令\subcaption
,該命令會產生 Karl 的答案中顯示的標題。如果您沒有嚴格綁定到該範本並希望使用套件中的正常標籤subcaption
,則必須取消定義該命令。這樣做的原因可能是您想引用一些subfigure
( \ref{fig:a}
) 正如所要求的這裡。
這可能如下所示:
% 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}
請注意,這不是提供該範本的編輯者的想法。在像這樣進行調整之前,您應該先與他們交談。也許,編號的副標題不適合整體設計。在這種情況下,您必須像這樣引用as you can see in Figure~\ref{fig:1} (left pic.)
答案3
好吧,看來我無法評論 LaRiFaRi 的答案,所以我在這裡寫...LaRiFaRi 的答案無法按原樣工作。我不知道為什麼,但我只能通過添加hyperref
包來使其工作。這是代碼:
\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}
結果影像:
答案4
事實證明,包含hyperref
還有一個效果:我可以使用
\begin{minipage}
...
\subcaption{...}
...
\end{minipage}
無需在任何地方明確地使用子圖環境。