Hyperref 导致 auto-pst-pdf 出现错误(chemstyle 使用)

Hyperref 导致 auto-pst-pdf 出现错误(chemstyle 使用)

在等待有用的建议来提高我的其他问题,我遇到了另一个与chemstyle包有关的问题:我的另一个问题的 MWE 确实适用于[TMP1]传递给的显式可选参数\schemeref,但当我添加\usepackage{hyperref}到序言时,一切都开始变得混乱。这是 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)

Error: /undefined in H.S在 期间出现了一个 aa auto-pst-pdf: Auxiliary LaTeX compilation(这就是为什么我假设问题是由hyperref和的相互作用引起的auto-pst-pdf),这会阻止 LaTeX 生成chimicaprova-pics.pdf具有 修改的方案的chemstyle

请注意,LaTeX 编译正确,没有错误,但输出的 pdf 中没有方案图像,标题上方只有空白。如果我将另一个方案添加到代码中(只需再复制粘贴一次\begin{scheme} ... \end{scheme}),在编译过程中发生的错误auto-pst-pdf: Auxiliary LaTeX compilation几乎保持不变,但这次 LaTeX 不会再编译:输出的最后几行现在是

(/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!

编辑:根据要求,我添加了一个完整的 MWE,它会产生错误。您可以找到 schema.eps 文件这里

\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

bpchem\CNlabel{<cpd>}最终或多或少会这样做。\ref{cn:<cpd>}现在\schemeref使用\psfrag(来自psfrag包)将 EPS 中的文本字符串替换为标签的 LaTeX 代码。但是,如果我没记错的话,超链接、pdflatex 和psfrag不能一起工作(但我不知道为什么)。我可以看到两种可能的解决方法:

  1. hyperref在使用 pdflatex 编译时加载,但在auto-pst-pdf完成辅助编译时不加载。
  2. 使用 latex+dvips+ps2pdf 编译

第一个版本:

% 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}

在此处输入图片描述

第二个版本:

% 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}

在此处输入图片描述

答案2

仅为pdflatex运行时加载 hyperref

\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}

在此处输入图片描述

相关内容