我正在使用subfig
和floatrow
来管理子图。没有floatrow
,一切正常,但我需要floatrow
轻松对齐标题,如subfig
手册所述。
调整手册第 37 页的示例并使用贡萨洛·梅迪纳 (Gonzalo Medina) 的帮助,我有这个代码:
\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}
\begin{document}
\thisfloatsetup{subfloatrowsep=none}
\begin{figure}[!htbp]
\captionsetup[subfigure]{justification=centering}
\floatbox{figure}{%
\caption{%
Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})%
}\label{fig:x}%
}{%
\begin{subfloatrow}%
\subfloat[Penguins were here and here and here]{%
\label{fig:a}\includegraphics[height=.1\textheight]{example-image-a}}
\qquad
\subfloat[Penguin]{%
\label{fig:b}\includegraphics[height=.15\textheight]{example-image-b}}
\qquad
\subfloat[Penguin]{%
\label{fig:c}\includegraphics[height=.125\textheight]{example-image-a}}
\end{subfloatrow}
\begin{subfloatrow}
\subfloat[Penguin]{%
\label{fig:d}\includegraphics[height=.15\textheight]{example-image-b}}
\qquad
\subfloat[Penguins were here, there and everywhere!]{%
\label{fig:e}\includegraphics[height=.2\textheight]{example-image-a}}
\end{subfloatrow}}
\end{figure}
\ref{fig:x} \ref{fig:a} \ref{fig:c} \ref{fig:e}
\end{document}
但显然标题编号有问题。这应该都是图 1,但它从 4 开始,然后又增加 2。我尝试将标签移动到不同的地方,但尽管 LaTeX 会告诉我参考资料已更改,但我仍然得到相同的结果。我也尝试过删除文件.aux
等。但同样,我仍然得到图 4 和子图 6。
正确的方法是什么?
答案1
这给出了正确的输出:
\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}
\begin{document}
\thisfloatsetup{subfloatrowsep=qquad}
\begin{figure}[!htbp]
\captionsetup[subfigure]{justification=centering}
\ffigbox{%
\begin{subfloatrow}[3]%
\ffigbox[\FBwidth]{\caption{Penguins were here and here and here}\label{fig:a}}{%
\includegraphics[height=.1\textheight]{example-image-a}}
\ffigbox[\FBwidth]{\caption{Penguin}\label{fig:b}}{%
\includegraphics[height=.15\textheight]{example-image-b}}
\ffigbox[\FBwidth]{\caption{Penguin}\label{fig:c}}{%
\includegraphics[height=.125\textheight]{example-image-a}}
\end{subfloatrow}
\begin{subfloatrow}
\ffigbox[\FBwidth]{\caption{Penguin}\label{fig:d}}{%
\includegraphics[height=.15\textheight]{example-image-b}}
\ffigbox[\FBwidth]{\caption{Penguins were here, there and everywhere!}\label{fig:e}}{%
\includegraphics[height=.2\textheight]{example-image-a}}
\end{subfloatrow}%
}{%
\caption{Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})\label{fig:x}}%
}
\end{figure}
\ref{fig:x} \ref{fig:a} \ref{fig:c} \ref{fig:e}
\end{document}
问题似乎是将floatrow
命令与 subfig结合起来\subfloat
(我猜想使用来自两个包的命令会使计数器以错误的方式移动(当每个包接管控制时,它都会移动计数器));一旦floatrow
仅使用命令完成所有操作,问题就会消失;请注意,这也会使
\thisfloatsetup{subfloatrowsep=qquad}
表现符合预期,因此现在不需要手动调整(我也在另一个问题)。