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.

I am using the chemscheme package and in order to replace numbering in these schemes I have in my document, I need to compile those eps files with latex, then dvips, and finally ps2pdf.

However, I have a very large number of images (upwards of 100, and it will only be increasing) that are perfectly fine to be used as the png they are in, or a precompiled pdf file. Since I need latex compilation for the chemscheme numbering, all those png or pdf images need to be in eps form, and it adds a solid 2-3 minutes to the compilation time.

Is there any solution for this type of situation?

I have read some solutions on here about packages like standalone and externalize but I confess to not fully understanding how to apply those solutions or if they even apply to this situation.

I thought I would add that without these extra images, my latex file compiles in about 30 secs, with the images it is now almost at 4 minutes compilation time :(

Here is an example of how the chemscheme package works (it is included as part of the chemstyle package. The file "reaction.eps" can be downloaded at the following link. The zip file also includes what the png looks like if you precompile it just on it's own (those TMP tags get replaced during the conversion process). The numbering commands \CNlabel and \CNlabelsub are sprinkled throughout the document, and they increment counters related to the compound numbering which is used in the replacement of the TMP tags within the images. However, only a handful of my images use these tmp tags and require this certain compilation. The rest have no TMP included and can be compiled externally without problem. In order to get the correct numbering, latex must be run twice, before calling dvips.

eps and pdf files: http://www.filedropper.com/reaction_1

\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{bpchem}
\usepackage[tracking=bpchem]{chemstyle}


\begin{document}

I am a document about methanol (\CNlabelsub{alcohol}{Me}), and the related alcohol isoamyl %
alcohol (\CNlabelsub{alcohol}{isoamy}).  \CNlabelsub{alcohol}{Me} can be converted to an alkyl %
halide with \BPChem{HCl} to give chloromethane (\CNlabel{MeCl}, \ref{sch:reaction}).
\begin{scheme}
\caption{I am a scheme}\label{sch:reaction}
\schemerefsub{alcohol}{Me}
\schemerefsub{alcohol}{isoamy}
\schemeref{MeCl}
\includegraphics{reaction}
\end{scheme}

\end{document}

Update, possible solution, but not quite finished

From Garbage Collector's answer, it did occur to me. I can provide a premade list of all the compounds in the document with a command \CNlabelnoref and \CNlabelsubnoref. I have done that, and below is a MWE using the standalone package. However, I now get an error a whole list of errors beginning at the \begin{figure} line, the first one being

LaTeX Error: Something's wrong--perhaps a missing \item.

\documentclass[border=0pt]{standalone}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{bpchem}
\usepackage[journal=rsc,tracking=bpchem]{chemstyle}
\renewcommand*{\schemerefformat}{\small\fontfamily{cmr}}
\newcommand{\chemdrawgraphic}[1]{\includegraphics[scale=1]{#1}}
\setcounter{BPCno}{200}
\CNlabelsubnoref{alcohol}{Me}
\CNlabelsubnoref{alcohol}{isoamy}
\CNlabelnoref{MeCl}
\begin{document}
\begin{figure}
    \schemerefsub{alcohol}{Me}
    \schemerefsub{alcohol}{isoamy}
    \schemeref{MeCl}
    \chemdrawgraphic{reaction}
\end{figure}
\end{document}
share|improve this question
    
externalize seems to mean the external library of tikz. That seems to be unrelated to chemscheme (at least tikz is not listed in its package dependencies). –  Christian Feuersänger Aug 31 '12 at 20:59
    
@ChristianFeuersänger This would be my indication of not fully understanding how to use those libraries :) hence looking for some guidance and a possible to solution to my problem –  J M Aug 31 '12 at 21:26
    
@JM -- why do you need to run latex rather than pdflatex? pdflatex wouldn't require any change to the png files. if the requirement excludes pdf output, the thing would be to use make to decide which eps needs changing since last compilation. –  wasteofspace Sep 1 '12 at 8:21
    
@wasteofspace The chemscheme package uses temporary text holders in the eps file which are later replaced during the compilation ps conversion with numbers from the document. Compilation directly to pdf bypasses this and result in the temporary text holders not being replaced. –  J M Sep 1 '12 at 8:24

2 Answers 2

up vote 2 down vote accepted

Compile each of diagram.tex files with latex-dvips-pspdf to get diagram.pdf.

% diagram.tex
\documentclass[border=0pt]{standalone}
\usepackage{chemscheme}
\begin{document}
% do your drawing
\end{document}

From within your main input file, import the diagram.pdf and other PNG, JPG, PDF images with \includegraphics. Compile the main input file with pdflatex.

share|improve this answer
1  
Unfortunately this will not work for the use of these documents. I've included an example of how chemscheme (which is included as part of the chemstyle package) works. Throughout the document there are those \CNlabel numbering commands so the compilation of the standalones must be aware of those numberings. –  J M Sep 1 '12 at 15:10
    
I've updated my question, and provided a new MWE. I have compiled a list of my compound references for use in standalone environments. However, I am now getting an error when I try to use the \begin{figure} command. Under my update is a new MWE. It uses the same eps file I have linked to in the post. –  J M Sep 1 '12 at 19:28

You can replace the temperary textholders when using pdfLatex, too. See for example this question: Chemnum/PS-Frag with EPS-Files and PNG-Files

From what I remember, chemscheme and chemnum do - in principle - the same thing when it comes to numbering of compounds in the text and in schemes or figures, so what has been said in the question mentioned above, should also apply in your case.

I have been using pdfLatex for some time with eps and png figures and it works fine, if you don't change font size dramatically.

Here I the MWE from the link above, that - however - uses chemnum instead:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % Modern font encoding
%\usepackage{pstool}
\usepackage{psfrag}
\usepackage[crop=off]{auto-pst-pdf} % Use EPS graphics with pdfLaTeX
\usepackage{booktabs} % Better table layouts
\usepackage[journal=rsc]{chemstyle} % Of course!
\usepackage{geometry} % Easy page layout
\usepackage{lmodern} % Use Latin Modern fonts
\usepackage[version=3]{mhchem} % Formula subscripts using \ce{}
\usepackage{xkeyval}
\usepackage{pst-pdf}
\usepackage{ifplatform}

\begin{document}
Test Test
\begin{figure} %% eps
\centering
\psfrag{goldhydrid}{test}
\includegraphics[scale=1.0]{./someeps}
\caption{A Caption}
\label{fig:someeps}
\end{figure}

\begin{figure} %% pngfile
\centering
\psfrag{goldhydrid}{test}
\includegraphics[scale=1.0]{./pngfile}
\caption{A Caption}
\label{fig:pngfile}
\end{figure}

\end{document}
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.