# Chemcompound package : how to avoid the listoffigures scan ?

Another chemcompounds package related question. Also maybe related to my first question relative to chemcompound and subfloat comportement here

So my question is how to avoid chemcompounds to scan from the beginning of the document that is the listoffigures ? Because I guess it is the case :

an example

If I have a compound that appears in position 3 in the tex normaly but that is refered in the listoffigures because present in the caption before than it will appear as in firts position ... An example is allways better (here with Axel Sommerfeldt patch for subcaption corretc numbering)

\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{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{wikoF}]{\rule{3cm}{2cm}}
\caption{Wiko E (\compound{wikoE}) and F (\compound{wikoF})}
\label{wikoEandF}

\end{figure}

\end{document}

-
–  cgnieder Nov 30 '12 at 14:37

It's the same problem as in the other question:

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


This disables (temporarily) the command that steps the counter and creates the reference.

With all respect to Axel, I find that

\makeatletter
\makeatother


instead of Axel's code for disabling the problem in subcaptions is more efficient.

-

The chemcompounds way would be to use \compound+ inside \caption. This only prints an already defined compound label. \compound* on the other hand allows to define a compound label without printing it.

You will need two latex runs to get the numbering right.

\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+{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