# How to define a new temporary label, with a separate counter, using chemnum?

Is there a way, using chemnum, to create a different type of TMP-label in .eps files which can then be replaced in the text with a separate label/numbering?

For example, I have many chemdraws which are numbered in the text (1, 2, 3...), but I want to have a separate label for ligands with their own counter (L1, L2, L3....).

Thanks

\documentclass{article}

\usepackage{graphicx}
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{chemnum}
\setchemnum{init,log=verbose}

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

% ligands
\resetcmpd
\initcmpd[pre-label-code=\textbf{L}]{L1.a,L2,L3.a}

\begin{document}

\begin{center}
\cmpdref{compound1} %replaces TMP1
\cmpdref{compound2} %replaces TMP2
\includegraphics{scheme.eps}
\end{center}

Here are two compounds: \refcmpd{compound1} and \refcmpd{compound2}.

\begin{center}
\setchemnum{replace-tag=L}
\cmpdref[tag=L1]{ligand1}
\includegraphics{ligand.eps}
\end{center}

Here is a ligand: \refcmpd{ligand1}

\end{document}

• I have never tried chemnum before, but an 'arbitrary' text label in an .eps file can be replaced using \psfrag. It does not work with pdflatex – user31729 May 10 '14 at 17:24
• Your example initiates completely different labels than the ones you use in the text... try initiating the ones you're actually using (i.e. compound1, compound2 and ligand1). Also, using tag=L1 makes setchemnum{replace-tag=L} useless as the tag gets overwritten, anyway. BTW: \cmpdref is deprecated in version 1.0. – clemens May 11 '14 at 14:09
• Sorry I'm fairly new to Latex! Thank-you, I believe I have it working now. So just to check, when you initiate a label you have to include all ID's used in the document? – chempixie May 11 '14 at 14:46
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. A suggestion: Do us a favour and change your username to something more telling than "user1234". – Martin Schröder May 12 '14 at 0:40

Edit:

Reading the question again I believe your question is not about tags to be replaced but a different set of labels? You should probably post a complete MWE illustrating what you want...

However, you can get two sets of labels by resetting the counter and setting a pre-label-code before defining the second set of labels. (This is completely independent from the replacing of the tags is the EPS files!) If you do this within the document you have to take care to keep the changes local or to undo the settings again after defining the new labels. It's easier to define them in the preamble then:

\documentclass{article}

\usepackage{chemnum}
\setchemnum{init,log=verbose}

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

% ligands
\resetcmpd
\initcmpd[pre-label-code=\textbf{L}]{L1.a,L2,L3.a}

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

Here are two ligands: \cmpd{L1.a} and \cmpd{L2}.

Here we have \cmpd{1} and \cmpd{2} again.

And now \cmpd{3.a}. Again \cmpd{2} but then \cmpd{L3.a}.
\end{document}


chemnum provides the means for this. The standard behavior is to replace tags TMP1, TMP2 etc, the numbering is local. This means if \replacecmpd is used within a group (usually an environment I guess) it starts from TMP1 again for the next figure. (The following examples use chemnum v1.0 syntax.)

\documentclass{article}
\usepackage{graphicx,auto-pst-pdf,chemnum}
\begin{document}

\begin{center}
\replacecmpd{compound1}% replaces TMP1
\replacecmpd{compound2}% replaces TMP2
\includegraphics{myscheme.eps}
\end{center}

\end{document}


One way to change this is a per-case basis:

\documentclass{article}
\usepackage{graphicx,auto-pst-pdf,chemnum}
\begin{document}

\begin{center}
\replacecmpd[tag=L1]{compound1}% replaces L1
\replacecmpd[tag=L2]{compound2}% replaces L2
\includegraphics{myscheme.eps}
\end{center}

\end{document}


But you can also change the TMP part of the tags with an option:

\documentclass{article}
\usepackage{graphicx,auto-pst-pdf,chemnum}
\begin{document}

\begin{center}
\setchemnum{replace-tag=L}
\replacecmpd{compound1}% replaces L1
\replacecmpd{compound2}% replaces L2
\includegraphics{myscheme.eps}
\end{center}

\end{document}

• I guess what I'm looking for is a combination of both of these features. So I can have one set of tags in my .eps file (like TMP1, TMP2 etc.) which will be one counter (in text 1, 2, 3...) and then another set of tags (like L1, L2...) in the .eps file which will have a separate counter with a separate label (in text L1, L2...). Hope this makes sense! – chempixie May 11 '14 at 13:32
• The definition of labels is independent from the replacement. How a replaced tag looks depends on which label you use. IMHO it should be possible to find a way from my answer. If it doesn't help you should update your question with a minimal working example that I can adapt – clemens May 11 '14 at 13:55