![化学化合物包和子浮点行为?](https://linux22.com/image/238593/%E5%8C%96%E5%AD%A6%E5%8C%96%E5%90%88%E7%89%A9%E5%8C%85%E5%92%8C%E5%AD%90%E6%B5%AE%E7%82%B9%E8%A1%8C%E4%B8%BA%EF%BC%9F.png)
我想使用化合物包允许您跟踪要引用的化合物,并在未指定任何内容时为它们指定数字顺序。我想在修改后的 subfloat 环境中使用它,这样就不会出现 (a)(b)。但是,如果首先插入 subfloat 环境中,化学化合物的行为很少见,并且不会以正确的方式编号。
我举一个例子来更清楚一点。
\documentclass{article}
\usepackage{graphics}
\usepackage{subfig}
\usepackage{caption}
\usepackage{chemcompounds}
\begin{document}
\begin{figure}[!ht]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfloat[\compound{wikoA}]{\rule{3cm}{2cm}}\quad
\subfloat[\compound{wikoB}]{\rule{3cm}{2cm}}
\caption{Wiko A and B}
\label{wikoAandB}
\end{figure}
Here are Wiko A \compound{wikoA} and B \compound{wikoB} see fig.\ref{wikoAandB}
Of course Wiko C and D are present \compound{wikoC,wikoD}
As well as Wiko E and F \compound{wikoE,wikoF} that you can see below. See fig. \ref{wikoEandF}
\begin{figure}[!ht]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfloat[\compound{wikoE}]{\rule{3cm}{2cm}}\quad
\subfloat[\compound{wikoF}]{\rule{3cm}{2cm}}
\caption{Wiko E and F}
\label{wikoEandF}
\end{figure}
\end{document}
有什么线索吗?
答案1
subfig 和 caption 包将对每个标题进行所谓的单行检查,以测试其是否适合单行。这样 \compound 将被评估两次,出于某种原因,我还没有评估过 \compound 宏不喜欢这样。
一种解决方法是告诉 caption 包忽略单行检查中的 \compound。请注意,这不是解决方案,而是一种(肮脏的)黑客行为,因为这会导致单行检查评估错误的宽度。因此,我明天会进一步调查,也许之后可以提供更好的解决方案。
附录:caption 包中有一个补丁可以适配 \footnotemark。不幸的是,这产生了\compound
负面影响 - 此错误将在 caption v3.2 中修复。此外,我已在此示例代码中用适当的补丁替换了该 hack:
\documentclass{article}
\usepackage{graphics}
\usepackage{caption}
\usepackage{subfig}
\usepackage{chemcompounds}
% Patch: Make \compound work inside (figure & table) captions
% Not neccessary for caption package version >= 3.2, but will not make any harm
\makeatletter
\let\caption@prepareslc@ORI\caption@prepareslc
\renewcommand\caption@prepareslc{%
\let\caption@g@stepcounter\stepcounter
\caption@prepareslc@ORI
\let\compound@ORI\compound
\def\compound{\let\stepcounter\caption@g@stepcounter\compound@ORI}%
}
\makeatother
\begin{document}
\begin{figure}[!ht]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfloat[\compound{wikoA}]{\rule{3cm}{2cm}}\quad
\subfloat[\compound{wikoB}]{\rule{3cm}{2cm}}
\caption{Wiko A and B}
\label{wikoAandB}
\end{figure}
Here are Wiko A \compound{wikoA} and B \compound{wikoB} see fig.\ref{wikoAandB}
Of course Wiko C and D are present \compound{wikoC,wikoD}
As well as Wiko E and F \compound{wikoE,wikoF} that you can see below. See fig. \ref{wikoEandF}
\begin{figure}[!ht]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfloat[\compound{wikoE}]{\rule{3cm}{2cm}}\quad
\subfloat[\compound{wikoF}]{\rule{3cm}{2cm}}
\caption{Wiko E and F}
\label{wikoEandF}
\end{figure}
\end{document}
附录:该软件包的 3.2 版caption
于 2011 年 8 月发布,因此只需更新 TeX 发行版就应该有所帮助 - 尤其是上面的补丁不再是必要的。