我有一个非常简单的问题,我无法解决。
我使用pdfLaTeX
最新的 MikTeX 和 WinEdt。我需要用它psfrag
来制作我的 EPS 图表,因此我应用了这个pstool
包。这个包一直到夏天都运行良好。
现在我打开了一个当时可以工作的文档,但相同的文档和工具链失败了:由pstool
失败启动的扩展 LaTeX 运行,并从 EPS 创建了一个空白的 PDF。
最小示例:
\documentclass[12pt,a4paper]{article}
\usepackage[margin=2cm,a4paper]{geometry}
\usepackage{hyperref}
\title{psfrag in pdflatex }
\usepackage{graphicx}
\usepackage{pstool}
\usepackage{bookmark}
\begin{document}
Test
\begin{figure}[h!]
\centering
\psfragfig[mode=errorstop,width=0.9\textwidth]{Pulley_movable}
\caption{The EPS image with psfragfig}
\end{figure}
\end{document}
有趣的是,删除hyperref
并bookmarks
解决问题并创建正确的 PDF!!!因此,我认为我的 LaTeX 配置基本正确。也许某个包坏了?有人能测试一下我的最小示例并报告吗?
这是运行的结果。请注意,有一个警告,没有找到包含psfrag
命令的 Pulley_movable.tex,但我省略了它们以避免出现任何问题。提供文件没有帮助:
Startup Folder: C:\Users\xxxx\Documents\Papers\pstool-problem
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11 Portable)
entering extended mode
(test.tex
LaTeX2e <2020-10-01> patch level 2
L3 programming layer <2020-10-27> xparse <2020-03-03>
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/base\size12.clo))
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/geometry\geometry.sty
...
...
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/generic/xkeyval\xkvutils.tex))
) (C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/l3kernel\expl3.sty
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/l3backend\l3backend-pdft
ex.def)))
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/bookmark\bookmark.sty
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/bookmark\bkm-pdftex.def)
)
No file test.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/hyperref\nameref.sty
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/refcount\refcount.sty)
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/generic/gettitlestring\gettitl
estring.sty))
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/context/base/mkii\supp-pdf.mki
i
[Loading MPS to PDF converter (version 2006.09.02).]
)
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/epstopdf-pkg\epstopdf-ba
se.sty)"
"
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11 Portable)
entering extended mode
(Pulley_movable-pstool.tex
LaTeX2e <2020-10-01> patch level 2
L3 programming layer <2020-10-27> xparse <2020-03-03>
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/base\size12.clo))
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/geometry\geometry.sty
...
...
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/generic/luatex85\luatex85.sty)
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/preview\prtightpage.def
))
No file test.oldaux.
No file Pulley_movable-pstool.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/hyperref\nameref.sty
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/latex/refcount\refcount.sty)
(C:\ProgramData\Npackd\MiKTeX\texmfs\install\tex/generic/gettitlestring\gettitl
estring.sty))
Package hyperref Warning: Rerun to get /PageLabels entry.
Preview: Fontsize 12pt
<Pulley_movable.eps>
Preview: Tightpage -32891 -32891 32891 32891
[1] [2] (Pulley_movable-pstool.aux)
LaTeX Warning: Temporary extra page added at the end. Rerun to get it removed.
)
Output written on C:\Users\xxxx\Documents\Papers\pstool-problem\Pulley_movab
le-pstool.dvi (2 pages, 4272 bytes).
Transcript written on C:\Users\xxxx\Documents\Papers\pstool-problem\Pulley_m
ovable-pstool.log.
Package pstool Warning: No file "Pulley_movable.tex" or "Pulley_movable-psfrag.
tex" can be found that may contain macros for "Pulley_movable.eps" on input lin
e 17.
(pstool-statusfile.txt)"
This is dvips(k) 2020.1 Copyright 2020 Radical Eye Software (www.radicaleye.com)
' TeX output 2020.11.11:1110' -> Pulley_movable-pstool.ps
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/base/tex.pro>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/config/alt-rule.pro>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/psfrag/psfrag.pro>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/l3backend/l3backend-dvips.pro>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/base/texps.pro>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/base/special.pro>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/dvips/base/color.pro>.
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/fonts/type1/public/amsfonts/cm/cmr8.pfb>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/fonts/type1/public/amsfonts/cm/cmr12.pfb>
<C:/ProgramData/Npackd/MiKTeX/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb>
[1<./Pulley_movable.eps>] [2<./Pulley_movable-pstool.out.ps>]
(pstool-statusfile.txt)"
Error: /typecheck in --div--
Operand stack:
1 0 0.0 -0.907531 a 65781.8
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- --nostringval-- 4 --nostringval-- %repeat_continue --nostringval--
Dictionary stack:
--dict:974/1684(ro)(G)-- --dict:0/20(G)-- --dict:113/200(L)-- --dict:178/300(L)--
Current allocation mode is local
Current file position is 89152
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1
(pstool-statusfile.txt)"
Overfull \hbox (113.53291pt too wide) in paragraph at lines 17--17
[][]
LaTeX Warning: Float too large for page by 140.75291pt on input line 18.
LaTeX Warning: `!h' float specifier changed to `!ht'.
[1
Non-PDF special ignored!
<special> header=psfrag.pro
{C:/ProgramData/Npackd/MiKTeX/texmfs/data/pdftex/config/pdftex.map}] [2 <./Pull
ey_movable.pdf>] (test.aux
! Undefined control sequence.
l.20 \HyPL@Entry
{0<</S/D>>}
?
我重新安装了 MikTeX,但没有任何效果。非常感谢您的帮助 - 谢谢!
答案1
主要问题是由于 LaTeX 的 shipout 代码发生变化而导致预览和 hyperref 之间不兼容,我已经在这里报告过:https://lists.gnu.org/archive/html/bug-auctex/2020-11/msg00000.html
由于这种不兼容性,ghostscript 调用失败,然后您会在 miktex 和 texlive 中遇到错误(但略有不同)。
在您的示例中,您可以通过不使用预览而是使用 pdfcrop 来解决这种不兼容性:
\usepackage[crop=pdfcrop]{pstool}
或者
\usepackage[crop=pdfcrop]{pstool}
\usepackage{bookmark}
\makeatletter
\AddToHook{env/document/begin}{%
\@ifpackageloaded{preview}{
\ifPreview
\let\Hy@FirstPageHook\relax
\let\Hy@EveryPageAnchor\relax
\fi}{}}
\makeatother
旁边还有错误
! Undefined control sequence.
l.20 \HyPL@Entry
这里的问题是该命令仅在 hyperref 的 dvips 驱动程序中定义。hyperref 通常会\providecommand
向 aux 添加一个,但是却缺少了这个,并且当 pstool 将 aux 与 pdftex 一起使用时也会出现错误。
解决方法是简单地提供命令(在加载超链接或书签后)
\usepackage{bookmark}
\makeatletter
\providecommand\HyPL@Entry[1]{}
\makeatother