尝试从 TikZ 导出 EPS 图形失败

尝试从 TikZ 导出 EPS 图形失败

我尝试在 Windows XP 下使用 MikTeX 2.8 输出 EPS 图形,并遵循从 TikZ 导出 eps 图形。我的问题是我无法运行那里给出的简单示例。

我正在使用的代码是从该线程逐字复制的:

\documentclass{article}
\usepackage{tikz}

% set up externalization
\usetikzlibrary{external}
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource" && 
dvips -o "\image".ps "\image".dvi}}
\tikzexternalize[shell escape=-enable-write18] % MikTeX uses a -enable-write18 instead of --shell-escape.

\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{document}

运行时我收到以下错误消息:

This is pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8)
entering extended mode
(C:/junk/untitled-2.tex
LaTeX2e <2009/09/24>
. . .
[Loading MPS to PDF converter (version 2006.09.02).]
)
===== 'mode=convert with system call': Invoking 'latex -halt-on-error -interaction=batchmode -jobname "untitled-2-figure0" "\def\tikzexternalrealjob{untitled-2}\input{untitled-2}" && dvips -o "untitled-2-figure0".ps "untitled-2-figure0".dvi' ========

! Package tikz Error: Sorry, the system call 'latex -halt-on-error -interaction=batchmode -jobname "untitled-2-figure0" "\def\tikzexternalrealjob{untitled-2}\input{untitled-2}" && dvips -o "untitled-2-figure0".ps "untitled-2-figure0".dvi' did NOT result in a usable output file 'untitled-2-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in 'untitled-2-figure0.log'. If you continue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.14 \end{tikzpicture}    

?     

有人能帮助我克服这个障碍吗?


我之前的帖子是在 Windows XP 系统上使用 Chrome 编写的,其中答案框将我限制为大约 600 个字符,并且不接受标记或换行符 :-(。我在使用 Chrome 的 Windows 7 系统上撰写这篇文章,答案框具有我需要的所有标记功能 - 非常奇怪。

以下是编译输出:

This is pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8) entering extended mode ("C:/Documents and Settings/Moshe/My Documents/test.tex" LaTeX2e <2009/09/24> . . .

===== 'mode=convert with system call': Invoking 'latex -enable-write18 -halt-on
-error -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob {test}\input{test}" && dvips -o "test-figure0".ps "test-figure0".dvi' ========

! Package tikz Error: Sorry, the system call 'latex -enable-write18 -halt-on-er ror -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob{te st}\input{test}" && dvips -o "test-figure0".ps "test-figure0".dvi' did NOT resu lt in a usable output file 'test-figure0' (expected one of .pdf:.jpg:.jpeg:.png :). Please verify that you have enabled system calls. For pdflatex, this is 'pd flatex -shell-escape'. Sometimes it is also named 'write 18' or something like  that. Or maybe the command simply failed? Error messages can be found in 'test- figure0.log'. If you continue now, I'll try to typeset the picture.

See the tikz package documentation for explanation. Type  H <return>  for immediate help.  ...                                              

l.14 \结束{tikzpicture}

我希望这篇文章比我之前的文章更容易阅读:-)

答案1

我尝试在我的 MikTeX 2.9 安装上重现您的示例,并发现了相同的错误消息。有趣的是,主 .log 文件包含提示“系统调用中的引号错误”。当我删除所有引号时,我得到了“禁止、限制”或类似的信息。似乎 MikTeX 在这里有奇怪的错误检查。

无论如何,只要我重新配置 TeXnicCenter 以添加-enable-write18开关,它就起作用了 - 并且它不再抱怨“引用错误”。

因此,我同意上述评论中的建议:我非常确定您“仅”需要弄清楚如何将开关添加-enable-write18到 TeX 编辑器中。如果您告诉我们您使用的编辑器,我们也许可以为您提供帮助。

对于 TeXnicCenter,其工作方式如下:转到“输出 >> 定义输出配置文件(Alt+F7)”。在那里,您应该在左侧看到不同的输出配置文件,在右侧,您会看到所涉及的程序,如“LaTeX 编译器路径”、“BibTeX”、“MakeIndex”。选择配置文件LaTeX=>PS,然后添加-enable-write18到“LaTeX 编译器路径”。之后的“LaTeX 编译器路径”应该类似于C:Program Files\MikTeX 2.9\miktex\bin\latex.exe -enable-write18

然后,重新编译你的.tex 文件。

我相信您可以为您喜欢的 TeX 编辑器找到类似的选项。

相关内容