我正在写论文,为此,我下载了我所在学院的 latex 模板来使用。自从第一次未经编辑地运行模板以来,我一直遇到编译错误。我在 Windows 10 上使用 MikTex 和 TexWorks。
我的问题 ( ) 的 MWEmyscript.tex
是:
\documentclass{book}
\usepackage[pspdf={-dAutoRotatePages=/None},pdfcrop={ --hires}]{auto-pst-pdf}
\usepackage[]{pstricks}
\usepackage{mwe}
\begin{document}
\begin{center}
\includegraphics{example-image-a.eps}
\end{center}
\begin{figure}[t]
\begin{pspicture}(0,0)(5,2)
\psgrid
\end{pspicture}
\end{figure}
\end{document}
我运行 TexWorks 后得到的控制台输出是:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.7)
entering extended mode
(myscript.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-07-17>
("C:\Program Files\MiKTeX\tex/latex/base\book.cls"
Document Class: book 2019/12/20 v1.4l Standard LaTeX document class
("C:\Program Files\MiKTeX\tex/latex/base\bk10.clo"))
("C:\Program Files\MiKTeX\tex/latex/auto-pst-pdf\auto-pst-pdf.sty"
("C:\Program Files\MiKTeX\tex/generic/iftex\ifpdf.sty"
("C:\Program Files\MiKTeX\tex/generic/iftex\iftex.sty"))
("C:\Program Files\MiKTeX\tex/latex/xkeyval\xkeyval.sty"
("C:\Program Files\MiKTeX\tex/generic/xkeyval\xkeyval.tex"
("C:\Program Files\MiKTeX\tex/generic/xkeyval\xkvutils.tex"
("C:\Program Files\MiKTeX\tex/generic/xkeyval\keyval.tex"))))
("C:\Program Files\MiKTeX\tex/latex/ifplatform\ifplatform.sty"
("C:\Program Files\MiKTeX\tex/latex/tools\shellesc.sty")
("C:\Program Files\MiKTeX\tex/generic/pdftexcmds\pdftexcmds.sty"
("C:\Program Files\MiKTeX\tex/generic/infwarerr\infwarerr.sty")
("C:\Program Files\MiKTeX\tex/generic/ltxcmds\ltxcmds.sty"))
("C:\Program Files\MiKTeX\tex/generic/catchfile\catchfile.sty"
("C:\Program Files\MiKTeX\tex/generic/etexcmds\etexcmds.sty"))
("C:\Program Files\MiKTeX\tex/generic/iftex\ifluatex.sty"))" "
"-------------------------------------------------"
"auto-pst-pdf: Auxiliary LaTeX compilation"
"-------------------------------------------------"
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.7)
entering extended mode
This is dvips(k) 2020.1 Copyright 2020 Radical Eye Software (www.radicaleye.com)
' TeX output 2020.08.04:1253' -> myscript-autopp.ps
<C:/Program Files/MiKTeX/dvips/base/tex.pro>
<C:/Program Files/MiKTeX/dvips/config/alt-rule.pro>
<C:/Program Files/MiKTeX/dvips/pstricks/pstricks.pro>
<C:/Program Files/MiKTeX/dvips/pstricks/pst-algparser.pro>
<C:/Program Files/MiKTeX/dvips/pst-tools/pst-tools.pro>
<C:/Program Files/MiKTeX/dvips/pstricks/pst-dots.pro>
<C:/Program Files/MiKTeX/dvips/l3backend/l3backend-dvips.pro>
<C:/Program Files/MiKTeX/fonts/type1/public/lm/lmss17.pfb>
<C:/Program Files/MiKTeX/dvips/base/special.pro>. [1
<C:/Program Files/MiKTeX/tex/latex/mwe/example-image-a.eps>] [2]
Error: /undefinedfilename in (-dAutoRotatePages=/None)
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:969/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1
"-------------------------------------------------"
"auto-pst-pdf: End auxiliary LaTeX compilation"
"-------------------------------------------------"
Package auto-pst-pdf Warning:
Creation of myscript-autopp.pdf failed.
This warning occured on input line 124.
Package auto-pst-pdf Warning:
Could not create myscript-pics.pdf. Auxiliary files not deleted.
This warning occured on input line 124.
("C:\Program Files\MiKTeX\tex/latex/pst-pdf\pst-pdf.sty"
("C:\Program Files\MiKTeX\tex/generic/iftex\ifxetex.sty")
("C:\Program Files\MiKTeX\tex/generic/iftex\ifvtex.sty")
("C:\Program Files\MiKTeX\tex/generic/luatex85\luatex85.sty")
("C:\Program Files\MiKTeX\tex/latex/graphics\graphicx.sty"
("C:\Program Files\MiKTeX\tex/latex/graphics\graphics.sty"
("C:\Program Files\MiKTeX\tex/latex/graphics\trig.sty")
("C:\Program Files\MiKTeX\tex/latex/graphics-cfg\graphics.cfg")
("C:\Program Files\MiKTeX\tex/latex/graphics-def\pdftex.def")))
("C:\Program Files\MiKTeX\tex/latex/pstricks\pstricks.sty"
("C:\Program Files\MiKTeX\tex/latex/xcolor\xcolor.sty"
("C:\Program Files\MiKTeX\tex/latex/graphics-cfg\color.cfg"))
("C:\Program Files\MiKTeX\tex/generic/xkeyval\pst-xkey.tex")
("C:\Program Files\MiKTeX\tex/generic/pstricks\pstricks.tex"
("C:\Program Files\MiKTeX\tex/generic/pstricks\pst-fp.tex"
`pst-fp' v0.05, 2010/01/17 (hv))
("C:\Program Files\MiKTeX\tex/generic/pgf/utilities\pgfutil-common.tex"
("C:\Program Files\MiKTeX\tex/generic/pgf/utilities\pgfutil-common-lists.tex"))
("C:\Program Files\MiKTeX\tex/generic/pgf/utilities\pgfkeys.code.tex"
("C:\Program Files\MiKTeX\tex/generic/pgf/utilities\pgfkeysfiltered.code.tex"))
("C:\Program Files\MiKTeX\tex/generic/pgf/utilities\pgffor.code.tex"
Loading pgffor.code.tex
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmath.code.tex"
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathcalc.code.tex"
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathutil.code.tex")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathparser.code.tex")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.code.tex"
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.basic.code.tex"
)
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.trigonometric.c
ode.tex")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.random.code.tex
")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.comparison.code
.tex")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.base.code.tex")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.round.code.tex"
) ("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.misc.code.tex
")
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfunctions.integerarithmet
ics.code.tex")))
("C:\Program Files\MiKTeX\tex/generic/pgf/math\pgfmathfloat.code.tex")))
`PSTricks' v2.97 <2019/05/11> (tvz,hv)
("C:\Program Files\MiKTeX\tex/generic/pstricks\pstricks.con"))
("C:\Program Files\MiKTeX\tex/generic/pstricks\pst-fp.tex"))
("C:\Program Files\MiKTeX\tex/latex/preview\preview.sty")
("C:\Program Files\MiKTeX\tex/latex/graphics-def\dvips.def")
("C:\Program Files\MiKTeX\tex/latex/environ\environ.sty"
("C:\Program Files\MiKTeX\tex/latex/trimspaces\trimspaces.sty"))))
("C:\Program Files\MiKTeX\tex/latex/mwe\mwe.sty"
("C:\Program Files\MiKTeX\tex/latex/lipsum\lipsum.sty"
("C:\Program Files\MiKTeX\tex/latex/l3kernel\expl3.sty"
("C:\Program Files\MiKTeX\tex/latex/l3backend\l3backend-pdfmode.def"))
("C:\Program Files\MiKTeX\tex/latex/l3packages/xparse\xparse.sty"
("C:\Program Files\MiKTeX\tex/latex/l3packages/xparse\xparse-generic.tex"))
("C:\Program Files\MiKTeX\tex/latex/lipsum\lipsum.ltd.tex"))
("C:\Program Files\MiKTeX\tex/latex/blindtext\blindtext.sty"
("C:\Program Files\MiKTeX\tex/latex/tools\xspace.sty"))) (myscript.aux)
("C:\Program Files\MiKTeX\tex/context/base/mkii\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
)
Preview: Fontsize 10pt
Preview: PDFoutput 1
LaTeX Warning: File `myscript-pics.pdf' not found on input line 10.
! Package pdftex.def Error: File `myscript-pics.pdf' not found: using draft set
ting.
See the pdftex.def package documentation for explanation.
Type H <return> for immediate help.
...
l.10 \includegraphics{example-image-a.eps}
?
我尝试了以下 SX 答案中建议的解决方案:
- suparnob10 的回答和沃纳的回答:添加
\graphicspath{{<first/path>}{<second/path>}...{<last/path>}}
- 重新安装 MikTex
- 安装 perl 和 ghostscript:除了安装它们之外,我还需要做什么才能使此解决方案标记为“已尝试”?我目前只安装了它们。
- 导入时添加
dvipsnames
为选项pstricks
导致我出现另一个错误:! LaTeX Error: Option clash for package pstricks.
。此冲突可能是trimspaces.sty
由于这是较早的一行。 auto-pst-pdf
按照pstricks
提示加载Bernard 对原帖的评论
我正在使用启用的 pdflatex 运行脚本-shell-escape
,因为这是必需的auto-psd-pdf
。
附言:我将其包含\begin{figure}\begin{pspicture}..\end{figure}
在 MWE 中只是为了强调pstricks
模板中需要该包。
更新
pspdf={-dAutoRotatePages=/None}
在加载时删除该选项时auto-pst-pdf
,按照@Ulrike Fischer 的建议,部分错误提示Error: /undefinedfilename in (-dAutoRotatePages=/None)
已被替换为:
Sorry, but pdfcrop did not succeed for the following reason:
MiKTeX could not find the script engine 'perl.exe' which is required to execute 'pdfcrop'.
Remedy:
Make sure 'perl.exe' is installed on your system.
The log file hopefully contains the information to get MiKTeX going again:
C:\Users\aashay\AppData\Local\MiKTeX\miktex\log\pdfcrop.log
但是,我的系统上确实安装了 perl:perl -v
在 cmd 中输入后,我得到:
This is perl 5, version 30, subversion 2 (v5.30.2) built for MSWin32-x64-multi-thread
日志文件pdfcrop.log
如下:
2020-08-04 15:38:50,326+0200 INFO pdfcrop - this process (3308) started by 'cmd' with command line: pdfcrop --hires myscript-autopp.pdf myscript-pics.pdf
2020-08-04 15:38:50,340+0200 FATAL pdfcrop.core - The script engine could not be found.
2020-08-04 15:38:50,340+0200 FATAL pdfcrop.core - Data: scriptEngine="perl.exe", scriptName="pdfcrop"
2020-08-04 15:38:50,340+0200 FATAL pdfcrop.core - Source: Libraries\MiKTeX\Core\Session\runperl.cpp:83
2020-08-04 15:38:50,341+0200 FATAL pdfcrop - The script engine could not be found.
2020-08-04 15:38:50,341+0200 FATAL pdfcrop - Info: scriptEngine="perl.exe", scriptName="pdfcrop"
2020-08-04 15:38:50,341+0200 FATAL pdfcrop - Source: Libraries\MiKTeX\Core\Session\runperl.cpp
2020-08-04 15:38:50,341+0200 FATAL pdfcrop - Line: 83
答案1
在 Windows 上,pspdf 选项中的等号有点问题。请尝试以下操作:
\ExplSyntaxOn
\newcommand\hashchar{}
\edef\hashchar{\c_hash_str}
\ExplSyntaxOff
%use \hashchar instead of =:
\usepackage[pspdf={-dAutoRotatePages\hashchar/None},pdfcrop={ --hires}]{auto-pst-pdf}
(或者删除 pspdf 选项,也许您不需要它......)
答案2
解决方案,对我来说是三重:
- 根据@Ulrike Fischer的建议,我删除了
pspdf
/并通过替换等号对其进行了编辑。 (就这一点而言,我接受了该问题的答案。) - (和 2.5.)我读有些人在安装 perl 之前安装 pdfcrop 时遇到了问题。另外,我之前安装了 strawberry perl。我卸载了 strawberry perl 并安装了 active perl(虽然我不知道这为什么会影响它。因此我很困惑它是双重的还是三重的 :P)。
- 然后我
pdfcrop
从 MiKTeX 控制台手动重新安装。
完成此操作后,我就能成功运行 MWE(并且通过归纳,也能成功运行我的主要论文文件)。
答案3
对于 Windows:
\usepackage[pspdf={-dAutoRotatePages\#/None},pdfcrop={ --hires}]{auto-pst-pdf}