1

I'm new to LaTeX and have been trying to solve this for a few hours now.

Hi everyone - I'm new to LaTeX and have been trying to solve this for a few hours now.

I'm trying to transfer compounds made in ChemDraw (that I've exported as .eps files) into LaTeX. My ideal goal would be to have LaTeX automatically number all my compounds as I put them in (i.e. if I add a compound in before all the others, the compounds would all automatically renumber).

So far, I've not even been able to convert one temporary label to the number "1". See below:

\begin{figure}

\begin{center}

\replacecmpd{TMPA}

    \includegraphics[scale=0.7]{Diagrams/"Taxol, Numbered".eps}

        \caption{Taxol}

\end{center}

\end{figure}

And here's the output

EPS file here: https://drive.google.com/open?id=1BWAuTo6YzSeLVQRIQaf4gzG5k5uw84qY

ChemDraw version: 16.0.1.4 (61)

I'm super confused about chemnum vs chemfig vs chemscheme and so far have not been able to get anywhere with any of them - please help!

Thanks for your time!

  • To replace a tag using the \replacecmpd command, put a text box with the content TMP1 in chemdraw and export the file to .eps. (If you have more than one compound per image, use TMP1, TMP2,...) Then you can use \replacecmpd{<key>} in your .tex file with <key> being a unique identifier that you can always use to refer to this compound (comparable to the label/ref approach). If you wish to compile your document using pdflatex you might be interested in using the auto-pst-pdf package. – leandriis Mar 30 at 14:49
  • Further information (and also some examples) can be found in the chemnum manual. If you have a specific problem, please make a minimal working example (MWE) that illustrates your issue and allows others to reproduce it. Unrelated to the question: Do not use the center environment inside a figure as it adds vertical white space. In order to horizontally center the image, you can use the \centering command instead. – leandriis Mar 30 at 14:52
  • @leandriis, I tried this, but it didn't work? It just says "TMP1" still. – Eli Nathan Mar 30 at 14:56
  • Could you try with a .eps file that does not contain spaces in its name? – leandriis Mar 30 at 15:00
  • Sadly still doesn't work - but thanks anyway for helping. – Eli Nathan Mar 30 at 15:03
0

I have not tried this for a few years, but I used Joseph Wright's chemstyle package as well as the auto-pst-pdf package to automatically number structures. Basically, you would export your structures in .eps with the TMP1, TMP2, etc. placeholders and then insert your pictures in the scheme environment, specifying a code/tag/label/etc for each molecule. The placeholders are then converted to numbers while typesetting. You can also refer to the molecules numbers using \compound{<your compound label>} in inline text. After fiddling and tinkering with old code, this example says it better:

\documentclass{minimal} 
\usepackage[crop=off,runs=2]{auto-pst-pdf}
\usepackage{chemstyle}

\begin{document}

\begin{scheme}[h] 
\centering
    \schemeref[TMP1]{msoc2c6f13}
    \schemeref[TMP2]{imc2c6f13}
        \includegraphics[scale=1]{pfaim}
    \caption{a chemscheme}
    \label{sch:pfaim}
\end{scheme}%

Mesylate \compound{msoc2c6f13} was converted to the N-fluoroalkylated imidazole \compound{imc2c6f13}.

\end{document}

Which will give you this result: chemscheme example There's a few caveats though, which you must be made aware of:

  • You will need to allow shell escape (i.e. data from your code going out and in your typesetting program, more explanations here: What are \immediate & \write18 and how does one use them?) for auto-pst-pdf to process your TMP tags. Depending on your typesetting habits, you might want to have it for all your documents or just a few. You should be able to allow it either from your typesetting program or the document (e.g. if you're using arara).
  • If you need some specific order in the numbering, you will need to declare the compounds in that order, using \compound*{...} (e.g. at the beginning of a section).
  • Sometime between 2016 and now, auto-pst-pdf defaulted the crop option; this causes the converted .eps to be cropped, and, in my test case, to lose parts of the structures. Hence the crop=off option.

For (a lot) more details, you should also read Joseph Wright's chemstyle manual, it is full of useful tricks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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