Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to have two sets of labels for numbering compounds throughout the document? Currently I'm using chemnum to make labels like 1, 2, 3a and so on. I want to introduce a new sequence of numbers, say, TS1, TS2... The only idea I have is to reset the counter right before I introduce new labels like this:

\documentclass[b5paper,12pt]{article}
\usepackage{chemnum}
\cmpdinit[init-sub = true]{1,2,3.{a,b}}
\newcommand*{\cmpdTS}[1]{\cmpd[cmpd-prefix=\bfseries{TS},cmpd-space={}]{#1}}
\begin{document}
Here are two compounds: \cmpd{1} and \cmpd{2}.

\cmpdreset
Here are two transition states: \cmpdTS{TS1.a} and \cmpdTS{TS2}.

Which of these two transition states is involved in transformation of \cmpd{1} to \cmpd{2}?

What about \cmpd{3.a}? It is formed from \cmpd{2} via \cmpdTS{TS3.a}.
\end{document}

But it's a bad idea because in the output I get: "What about 3a? It is formed from 2 via TS4a." instead of: "What about 3a? It is formed from 2 via TS3a." because of the resetting the counter.

share|improve this question
1  
You're missing a dot in \cmpdinit. Change it to \cmpdinit[init-sub = true]{1,2,3.{a,b}}. –  cgnieder Sep 17 '12 at 20:03
    
Thanks for pointing out the mistake:-) Am I right that this method will work if I initiate all the labels for one sequence in, for example, preamble and then just reset the counter before I need to introduce a new sequence? –  Ilya Makarov Sep 17 '12 at 20:12
    
Yes, that should work. –  cgnieder Sep 17 '12 at 20:30
    
The dot fixes the issue (in case that wasn't clear from my earlier comment) –  cgnieder Sep 17 '12 at 20:31

1 Answer 1

up vote 4 down vote accepted

Original answer

The line

\cmpdinit[init-sub = true]{1,2,3{a,b}}

initates three labels: 1, 2 and 3{a,b}. Every further label used in the text will still be created (and write a warning in the log that it hasn't been initiated). Thus the numbering goes:

Here are two compounds: \cmpd{1} and \cmpd{2}.% numbers 1 and 2

\cmpdreset% new numbers will start at 1 again
Here are two transition states: \cmpdTS{TS1.a} and \cmpdTS{TS2}.
% 1a and 2

Which of these two transition states is involved in transformation of \cmpd{1} to \cmpd{2}?
% 1 and 2 again

What about \cmpd{3.a}? It is formed from \cmpd{2} via \cmpdTS{TS3.a}
% `3' was never declared but gives `3' as this is the next number to be declared,
%`TS3' consequently gives `4`

So what you want is this:

\cmpdinit[init-sub = true]{1,2,3.{a,b}}

which initiates labels 1, 2 and 3 and the sublabels 3.a and 3.b.

You could have seen this easier by using the option init-strict which will cause errors if an uninitiated label is used. My suggestion would be to do something like the following, i.e. declare every label in the preamble together with init-strict:

\documentclass[b5paper,12pt]{article}

\usepackage{chemnum}
\cmpdsetup{init-strict,init-sub}% error if unititialized label is used

% regular labels
\cmpdinit{1,2,3.a}

% transition states
\newcommand*{\cmpdTS}[1]{\cmpd[cmpd-prefix=\textbf{TS},cmpd-space={}]{#1}}
\cmpdreset
\cmpdinit{TS1.a,TS2,TS3.a}

\begin{document}
Here are two compounds: \cmpd{1} and \cmpd{2}.

Here are two transition states: \cmpdTS{TS1.a} and \cmpdTS{TS2}.

Which of these two transition states is involved in transformation of \cmpd{1} to \cmpd{2}?

What about \cmpd{3.a}? It is formed from \cmpd{2} via \cmpdTS{TS3.a}.
\end{document}

Edit 2014/03/14

Since 2014/03/12 version 1.0 of chemnum is available. This this new release comes with a change in many ways I'd like to give the solution for the new version as well:

\documentclass[b5paper,12pt]{article}

\usepackage{chemnum}[2014/03/12]
\setchemnum{init,log=verbose}

% regular labels
\initcmpd{1,2,3.a}

% transition states
\resetcmpd
\initcmpd[pre-label-code=\textbf{TS}]{TS1.a,TS2,TS3.a}

\begin{document}
Here are two compounds: \cmpd{1} and \cmpd{2}.

Here are two transition states: \cmpd{TS1.a} and \cmpd{TS2}.

Which of these two transition states is involved in transformation of \cmpd{1}
to \cmpd{2}?

What about \cmpd{3.a}? It is formed from \cmpd{2} via \cmpd{TS3.a}.
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.