Chemcompound 包:如何避免 listoffigures 扫描?

Chemcompound 包:如何避免 listoffigures 扫描?

其他化合物包相关的问题。也可能与我的第一个关于 chemcompound 和 subfloat 行为的问题有关这里

所以我的问题是如何避免从文档开头(即图片列表)扫描化学化合物?因为我猜是这样的:

一个例子

如果我有一个化合物,它通常出现在文本的第 3 位,但是由于它出现在标题之前而在图片列表中被引用,那么它将出现在第一位... 举个例子总是更好的(这里使用 Axel Sommerfeldt 补丁对子标题进行更正编号)

\documentclass{article}
\usepackage{graphics}
\usepackage{subfig}
\usepackage{caption}
\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}
\listoffigures



\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 (\compound{wikoE}) and F (\compound{wikoF})}
  \label{wikoEandF}



\end{figure}

\end{document} 

答案1

这和另一个问题是一样的:

\begingroup\makeatletter
\renewcommand\@createcompound[2][]{}
\listoffigures
\endgroup

这将(暂时)禁用步进计数器和创建引用的命令。

尽管我对阿克塞尔怀有敬意,但我发现

\makeatletter
\g@addto@macro\caption@prepareslc{\renewcommand\@createcompound[2][]{}}
\makeatother

而不是 Axel 的代码来禁用子字幕中的问题更加有效。

答案2

方法chemcompounds是使用\compound+inside \caption。这只会打印已定义的复合标签。\compound*另一方面,允许定义复合标签没有打印它。

您需要latex运行两次才能获得正确的编号。

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{caption}
\usepackage{chemcompounds}

\begin{document}
\listoffigures

\compound*{wikoA}\compound*{wikoB}% invisible markers
\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 (\compound+{wikoE}) and F (\compound+{wikoF})}
  \label{wikoEandF}
\end{figure}

\end{document}

在此处输入图片描述

相关内容