使用 tikz 术语在 Gnuplot 中管理奇怪的 tex 文件

Strange tex files management in Gnuplot with tikz term

我发现了一个奇怪的现象。如果我们 运行 下面的 gnuplot 脚本(在 gnuplot-lua-tikz-common.tex、gnuplot-lua-tikz.sty、gnuplot-lua-tikz.tex, t-gnuplot-lua-tikz.tex)

tikzfile="test.tex"
plot x**2
set term tikz standalone monochrome
set output tikzfile #
replot              #
cmd="pdflatex -interaction=nonstopmode ". tikzfile
system(cmd)

我们发现了以下致命错误

! Emergency stop.
<*> test.tex

!  ==> Fatal error occurred, no output PDF file produced!

无论如何我们有 test.tex 文件。因此,如果我们重新 运行 带有 # 标记行的相同脚本,我们将不会出现错误,并且会得到完美的 test.pdf 文件。

在第一次执行期间,使用 set term 我们有一个空文件,使用 replot 我们填充它,但是直到结束我们不能将 exec 用作 pdflatex 的输入。为什么?

在第二次执行期间我们已经有了 test.tex 文件,所以如果我们评论 set termreplot 我们可以将其用作 pdflatex 的输入。为什么?

谢谢。

Gnuplot 不会在 plot 之后自动刷新并完成输出文件。

因此,如果您想进一步处理 gnuplot 脚本中的输出文件,您必须事先使用 set output 显式关闭该文件:

tikzfile="test.tex"
set term tikz standalone
set output tikzfile
plot x**2

set output
cmd="pdflatex -interaction=nonstopmode ". tikzfile
system(cmd)