2

While waiting for useful tips to improve my other question, I'm facing another problem with chemstyle package: the MWE of my other question does work with the explicit [TMP1] optional argument passed to \schemeref, but when I add \usepackage{hyperref} to the preamble everything starts to mess up. Here is the ouput of LaTeX.

*****
*****     PDFLaTeX risultato: 
*****     cd "/home/andrea/Dropbox/LaTeX/provatesi"
*****     pdflatex --shell-escape -synctex=1 -interaction=nonstopmode chimicaprova.tex
*****
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
(./chimicaprova.tex
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 28 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu)))
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
(/usr/share/texlive/texmf-dist/tex/generic/babel-italian/italian.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def)))
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty
(/usr/share/texlive/texmf-dist/tex/latex/etex-pkg/etex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty)
(/usr/share/texlive/texmf-dist/tex/latex/auto-pst-pdf/auto-pst-pdf.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(/usr/share/texlive/texmf-dist/tex/latex/ifplatform/ifplatform.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/catchfile.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty))
(./chimicaprova.w18)) 
-------------------------------------------------
auto-pst-pdf: Auxiliary LaTeX compilation
-------------------------------------------------
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=latex)
entering extended mode
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=latex)
entering extended mode
This is dvips(k) 5.994 Copyright 2014 Radical Eye Software (www.radicaleye.com)
' TeX output 2015.07.23:1929' -> chimicaprova-autopp.ps
dvips: Font Helvetica used in file img/schema1.eps is not in the mapping file.
dvips: Font Times-Roman used in file img/schema1.eps is not in the mapping file.
</usr/share/texlive/texmf-dist/dvips/base/tex.pro>
</usr/share/texlive/texmf-dist/dvips/config/alt-rule.pro>
</usr/share/texlive/texmf-dist/dvips/pstricks/pstricks.pro>
</usr/share/texlive/texmf-dist/dvips/pstricks/pst-algparser.pro>
</usr/share/texlive/texmf-dist/dvips/pst-tools/pst-tools.pro>
</usr/share/texlive/texmf-dist/dvips/pstricks/pst-dots.pro>
</usr/share/texlive/texmf-dist/dvips/psfrag/psfrag.pro>
</usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-t1.enc>
</usr/share/texlive/texmf-dist/dvips/base/texps.pro>
</usr/share/texlive/texmf-dist/dvips/base/special.pro>
</usr/share/texlive/texmf-dist/dvips/base/color.pro>. 
</usr/share/texmf/fonts/type1/public/cm-super/sfsx1000.pfb>
</usr/share/texmf/fonts/type1/public/cm-super/sfrm1000.pfb>[1
<./img/schema1.eps>] 
Error: /undefined in H.S
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1967   1   3   %oparray_pop   1966   1   3   %oparray_pop   1950   1   3   %oparray_pop   1836   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1187/1684(ro)(G)--   --dict:1/20(G)--   --dict:123/200(L)--   --dict:183/300(L)--   --dict:19/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 167246
GPL Ghostscript 9.15: Unrecoverable error, exit code 1
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `chimicaprova-pics.pdf'.
-------------------------------------------------
auto-pst-pdf: End auxiliary LaTeX compilation
-------------------------------------------------

(/usr/share/texlive/texmf-dist/tex/latex/pst-pdf/pst-pdf.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def)))
(/usr/share/texlive/texmf-dist/tex/latex/pstricks/pstricks.sty
(/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/pst-xkey.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pstricks/pst-fp.tex
`pst-fp' v0.05, 2010/01/17 (hv))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.t
ex)) (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.t
ex)) (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code
.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonomet
ric.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.cod
e.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison
.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code.
tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code
.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.
tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerari
thmetics.code.tex)))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)))
`PSTricks' v2.57  <2014/08/27> (tvz)
(/usr/share/texlive/texmf-dist/tex/generic/pstricks/pstricks.con))
(/usr/share/texlive/texmf-dist/tex/generic/pstricks/pst-fp.tex)
(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg)))
(/usr/share/texmf/tex/latex/preview/preview.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/dvips.def)
(/usr/share/texlive/texmf-dist/tex/latex/environ/environ.sty
(/usr/share/texlive/texmf-dist/tex/latex/trimspaces/trimspaces.sty))))
(/usr/share/texlive/texmf-dist/tex/latex/chemstyle/chemstyle.sty
(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty
(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty))
(/usr/share/texlive/texmf-dist/tex/latex/chemstyle/chemscheme.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/psfrag/psfrag.sty))
(/usr/share/texlive/texmf-dist/tex/latex/tools/xspace.sty)
(/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3unicode-data.def)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator.sty
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator-language-
mappings.tex))) (/usr/share/texlive/texmf-dist/tex/latex/floatrow/floatrow.sty)
(/usr/share/texlive/texmf-dist/tex/latex/bpchem/bpchem.sty))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(./chimicaprova.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
Preview: Fontsize 10pt
Preview: PDFoutput 1
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/dicts/translator-bas
ic-dictionary/translator-basic-dictionary-English.dict)
(/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./chimicaprova.out) (./chimicaprova.out)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)
<chimicaprova-pics.pdf, id=5, page=1, 342.27875pt x 51.19125pt>
<use chimicaprova-pics.pdf, page 1> [1
Non-PDF special ignored!
Non-PDF special ignored!
Non-PDF special ignored!{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map} <./
chimicaprova-pics.pdf>] (./chimicaprova.aux) ){/usr/share/texmf/fonts/enc/dvips
/cm-super/cm-super-t1.enc}</usr/share/texmf/fonts/type1/public/cm-super/sfrm100
0.pfb>
Output written on chimicaprova.pdf (1 page, 15008 bytes).
SyncTeX written on chimicaprova.synctex.gz.
Transcript written on chimicaprova.log.
okular(5923) Okular::Utils::realDpiY: Pix: 1050 MM: 278
okular(5923) Okular::Utils::realDpiX: Pix: 3360 MM: 889
okular(5923) Okular::DocumentPrivate::openDocumentInternal: Output DPI: QSizeF(96, 95.9353)

There is aa Error: /undefined in H.S which occurs during the auto-pst-pdf: Auxiliary LaTeX compilation (that's why I suppose that the problem is caused by the interaction of hyperref and auto-pst-pdf) which prevents LaTeX from generating the chimicaprova-pics.pdf with the schemes modified by chemstyle.

Note that LaTeX compiles correctly without errors, but the output pdf has no scheme image inside, there is only a blank space over the caption. If I add another scheme to the code (simply copy-pasting the \begin{scheme} ... \end{scheme} one more time) the error occuring during the auto-pst-pdf: Auxiliary LaTeX compilation remains almost the same, but this time LaTeX won't compile anymore: the last lines of the output now are

(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)
<chimicaprova-pics.pdf, id=5, page=1, 342.27875pt x 51.19125pt>
<use chimicaprova-pics.pdf, page 1>
!pdfTeX error: /usr/bin/pdflatex (file ./chimicaprova-pics.pdf): PDF inclusion:
 required page does not exist <1>
 ==> Fatal error occurred, no output PDF file produced!

Edit: as requested I add a complete MWE which produces the error. You can find the schema.eps file here.

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage[varioref=false, tracking=bpchem]{chemstyle}
\usepackage{hyperref} % comment this line and everything works fine

\begin{document}
\begin{scheme}
\schemeref[TMP1]{MetBr}
\schemeref[TMP2]{Mg0}
\schemeref[TMP3]{MetMgBr}
\includegraphics[width=\columnwidth]{schema1}
\end{scheme}
\end{document}
  • 1
    I have no problem with the example from your previous question and loading hyperref. Giv a complete example which shows the error. – user2478 Jul 23 '15 at 18:01
  • I've edited the question and added a complete MWE: if I compile that code I get the error I wrote about. – Rackbox Jul 24 '15 at 7:33
  • I get the conversion but do see some GhostScript complaints and loose the text in the figure. Looks like a defective EPS to me: not anything I control at the macro level. – Joseph Wright Jul 24 '15 at 16:05
1

bpchem's \CNlabel{<cpd>} in the end more or less does \ref{cn:<cpd>}. \schemeref now uses \psfrag (from the psfrag package) to replace the text string in the EPS with the LaTeX code for the label. However, if memory serves me right, hyperlinks, pdflatex and psfrag don't work together (I don't know why, though). There are two possible workarounds that I can see:

  1. Only load hyperref when compiling with pdflatex but not when auto-pst-pdf's auxiliary compilations are done.
  2. Compile with latex+dvips+ps2pdf

The first version:

% arara: pdflatex: { shell: on }
% arara: pdflatex: { shell: on }
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{graphicx}
\usepackage[runs=2]{auto-pst-pdf}
\usepackage[varioref=false, tracking=bpchem]{chemstyle}

\makeatletter
% auto-pst-pdf loads ifpdf
\ifpdf
  \expandafter\@firstofone
\else
  \expandafter\@gobble
\fi
{\usepackage{hyperref}}
\makeatother

\begin{document}

\begin{scheme}
  \schemeref{MetBr}
  \schemeref{Mg0}
  \schemeref{MetMgBr}
  \includegraphics[width=\linewidth]{schema1}
  \caption{my caption}\label{sch:my-scheme}
\end{scheme}

See scheme~\ref{sch:my-scheme}

\end{document}

enter image description here

The second version:

% arara: latex
% arara: latex
% arara: dvips
% arara: ps2pdf
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{graphicx}
% \usepackage[runs=2]{auto-pst-pdf}
\usepackage[varioref=false, tracking=bpchem]{chemstyle}

\usepackage{hyperref}

\begin{document}

\begin{scheme}
  \schemeref{MetBr}
  \schemeref{Mg0}
  \schemeref{MetMgBr}
  \includegraphics[width=\linewidth]{schema1}
  \caption{my caption}\label{sch:my-scheme}
\end{scheme}

See scheme~\ref{sch:my-scheme}

\end{document}

enter image description here

  • I tried the first solution you propose, and at least it makes LaTeX produce a pdf output with the TMPX markers correctly substituted in the images. But I can't reference compounds: using \CNref{MetBr} leads to "Reference undefined". About the second solution: I'm using Kile as editor and compiler, and I first have to figure out how to edit its compiling behaviour. Since now I've always used the default settings! – Rackbox Jul 24 '15 at 10:46
  • 1
    @Rackbox add \CNlabelnoref{MetBr} inside the scheme environment – clemens Jul 24 '15 at 10:49
  • Or (if the compound labels don't need to be hyperlinks) switch to the chemnum package – clemens Jul 24 '15 at 10:50
  • 1
    @Rackbox sorry to be a nitpicker but it is not chemstyle which does the labeling but the bpchem package :p – clemens Jul 24 '15 at 10:57
  • 1
    @Rackbox it's on my TODO list for a year now: github.com/cgnieder/chemnum/issues/4 As for the scheme environment: the upcoming update (or rather successor package) of chemmacros will provide a scheme environment. But it's easy to define yourself, anyway: tex.stackexchange.com/a/114933/5049 or tex.stackexchange.com/a/96493 or texwelt.de/wissen/fragen/2854 – clemens Jul 24 '15 at 11:12
0

Load hyperref only for the pdflatex run

\documentclass{article} 
\usepackage[runs=2]{auto-pst-pdf}
\usepackage{bpchem}
\usepackage[tracking=bpchem]{chemstyle}
\usepackage[version=3]{mhchem}

\ifpdf
\usepackage{letltxmacro}
\LetLtxMacro\oldschemeref\schemeref
\DeclareRobustCommand{\schemeref}[2][]{%
    \CNlabelnoref{#2}%
    \oldschemeref[#1]{#2}%
}
\usepackage{hyperref}
\fi

\begin{document}
\begin{scheme}
    \schemeref{comp1}
    \schemeref{comp2}
    \schemeref{comp3}
    \includegraphics[width=\columnwidth]{schema1}
\end{scheme}

    Compound number \CNref{comp1}, compound number \CNref{comp2}.
\end{document}

enter image description here

  • If I do this way the image temporary markers (TMP1, TMP2, ecc...) are not substituted with numbers by the chemstyle package. It seems that saving the image in a box prevents chemstyle to do its work. The correct output (obtained commenting the \usepackage{hyperref} line) should be this. – Rackbox Jul 24 '15 at 9:58
  • see edited answer – user2478 Jul 24 '15 at 16:30

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.