I am writing an organic chemistry dissertation using (pdf)LaTeX. The content of the thesis contains a large amount of numbered chemical structures. The chemical structure drawings were generated using ChemDraw and exported to eps format. Since there are literally hundreds of numbered structures, I wrote a macro that uses a custom counter to keep track of the numbers:
\newcounter{compound}
\def\thecompound{\textbf{\thechapter.\arabic{compound}}}
\newcommand{\cmp}[1]{\refstepcounter{compound}\label{cmp:#1}\textsf{\scriptsize{\thecompound}}}
Each time I want to number a compound, I simply write the command (which automatically increments the counter):
\cmp{uniquestring}
The problem I am having is finding an efficient way to put the compound numbers on the structural drawings (eps figures). What I am using right now is a floating text block over the image that I have to manually align. Here is an example of one of my figures (I defined a custom float called a Scheme):
\begin{Scheme}[h]
\centering \includegraphics[scale=0.8]{chp_diazobkg/images/shioiritwo}
\begin{textblock}{1}(1.65,-0.8) \cmp{aax} \end{textblock}
\begin{textblock}{1}(7,-1) \cmp{aay} \end{textblock}
\begin{textblock}{1}(13,-1) \cmp{aaz} \end{textblock}
\begin{textblock}{1}(17.5,-0.5) \cmp{aba} \end{textblock}
\caption{Facile [1,3]-Brook rearrangement of $\alpha$-keto silane intermediate \ref{cmp:aay}.}
\label{sch:shioiritwo}
\end{Scheme}
Ideally what I would like to be able to do is use a package like pstool/psfrag so that the unique identifiers could be built into the eps file and get replaced with the compound numbers. Using the pstool package, I am able to do text replacements in eps figures, but when I try to do a replacement with a counter psfrag chokes and can't generate the figure. The code below works fine for me so I know the package is installed correctly.
\psfragfig[scale=0.8]{test}{
\psfrag{[aaa]}{testing}
}
However, when I try to do something like this no luck (in fact the whole package breaks and no image is generated):
\psfragfig[scale=0.8]{test}{
\psfrag{[aaa]}{\cmp{xxx}}
}
Or even something simpler like this just gives ?? for the replaced text:
\psfragfig[scale=0.8]{test}{
\psfrag{[aaa]}{\ref{somefigure}}
}
Any suggestions would be greatly appreciated.
I have posted a minimal working example with EPS files at: https://sites.google.com/site/vrendina/latex
chemnumfor this task. – cgnieder Jan 19 at 7:48chemschemepackage is not dissimilar to the one you outline (today I would also recommendchemnum, but that's a different issue). Could you provide a small MWE of your input (i.e a complete document), including an EPS somewhere we can get hold of for testing? – Joseph Wright♦ Jan 19 at 8:23[aaa]. The??might mean that the labelsomefigureis not defined. At this point, you really have to provide a MWE. – mafp Jan 19 at 10:11\psfragfigas defined byauto-pst-pdfthen your syntax is wrong. The last argument is optional:\psfragfig[scale=0.8]{scheme}[\psfrag{TMP}{\cmp{xxx}}]. – cgnieder Jan 19 at 13:36