3

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!

Eli Nathan
  • 51
  • 2
  • 6
  • 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 '19 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 '19 at 14:52
  • @leandriis, I tried this, but it didn't work? It just says "TMP1" still. – Eli Nathan Mar 30 '19 at 14:56
  • Could you try with a .eps file that does not contain spaces in its name? – leandriis Mar 30 '19 at 15:00
  • Sadly still doesn't work - but thanks anyway for helping. – Eli Nathan Mar 30 '19 at 15:03
  • In that case, could you please add which version of chemdraw you use and maybe also a link to the .eps file that you include in your tex file? – leandriis Mar 30 '19 at 15:04
  • Done - ChemDraw version 16.0.1.4 (61) – Eli Nathan Mar 30 '19 at 15:07
  • With version 16 of chemdraw apparently the generation of .eps files has changed. A related question can be found here: Chemnum with Chemdraw 16.0.1.4 not working – leandriis Mar 30 '19 at 15:09
  • So I saw this, which is why I tried instead using the label "TMPA" over "TMP1", but this again did not work. I later tried just "TMP" on its own. I also can't edit the EPS files as I just have a mac and am using Overleaf online. – Eli Nathan Mar 30 '19 at 16:02
  • I've looked through the .eps file that you linked to in your question and did not find any way to make the replacement work directly. If you have acces to it, I would either recommend to use an older version of chemdraw. Alternatively (and not at all elegant) you could use inkscape (tested with version0.91) to add a textbox containing a single letter tag to your .eps file. Then the replacement works using the following command \replacecmpd[tag=X]{TMPA} assuming that X is the tag you chose to add. – leandriis Mar 30 '19 at 17:00
  • Okay - so I went ahead and downloaded an old version of ChemDraw - and did all the same steps, but it still doesn't work! – Eli Nathan Mar 30 '19 at 17:43
  • The v16 EPS as Supplied in comparison to others v17 that Change from TMP1 etc does not have a suitable tag so would go with the prior comment that version 16 seems to be one issue another is previous problems suggested using shell-escape to run epstopdf on one pass then comment out for second run when change happens the mwe does not have a preamble or chem num format and the EPS name should be simplified to just plain TaxolNumbered with no extension for eps to pdf to work –  Mar 31 '19 at 03:53
  • Yeah so I appreciate your help @KJO but I really have no idea what you're saying – Eli Nathan Apr 19 '19 at 13:52
  • ok break it down 1) do not use 16 2) simplify filenames taxol-num.eps avoid space comma hash etc.etc –  Apr 19 '19 at 13:57
  • Thanks but I have already done both of these and it still does not work – Eli Nathan Apr 19 '19 at 14:28
  • SOLVED: My "compiler" in Overleaf was set as pdfLaTeX rather than just LaTeX! – Eli Nathan Apr 19 '19 at 15:37

1 Answers1

1

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.

v_manz
  • 305