软件包 tikz 错误:抱歉,系统调用“xelatex -halt-on-error -interactix -shell-escape”带有外部 PGFPlot 和 TikZ

软件包 tikz 错误:抱歉,系统调用“xelatex -halt-on-error -interactix -shell-escape”带有外部 PGFPlot 和 TikZ

我一直在尝试使用外部 PGFPlot 和 TikZ,因为我一直遇到内存不足的问题,似乎将图形外部化为单独的 pdf 进行缓存是推荐的解决方案。但每当我尝试外部化文档时,我都会遇到错误。

错误:

Package tikz Error: Sorry, the system call 'xelatex -halt-on-error -interactix -shell-escape'. Sometimes it is also named 'write 18' or something like that.

当我放弃尝试外部化时错误就消失了,但这不是我的目标。

代码:

\documentclass[margin=2cm]{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}
\usepgfplotslibrary{units}
\usepgfplotslibrary{external} % Comment out to make it run without error
\tikzexternalize[prefix=cache/]{main} % Comment out to make it run without error
\usepackage{tikz}
\usetikzlibrary{external} % Comment out to make it run without error
\usetikzlibrary{pgfplots.external} % Comment out to make it run without error
\usepackage[binary-units=true]{siunitx}

\begin{document}

    \begin{figure}
        \begin{tikzpicture}
            \begin{groupplot}[
                group style={
                    group size=2 by 1,
                    horizontal sep=40pt,
                    vertical sep=20pt,
                },
                x unit=\si{\byte},
                y unit=\si{\second},
                ]
                
                \nextgroupplot
                \addplot {x};
                
                \nextgroupplot
                \addplot {x^3};
            \end{groupplot}
        \end{tikzpicture}
    \caption{Text describing the plots.}
    \label{plot:graphs}
    \end{figure}

    Look at plot \ref{plot:graphs} for details.

\end{document}

日志文件(完整日志这里):

===== 'mode=convert with system call': Invoking 'xelatex -halt-on-error -intera
ction=batchmode -jobname "cache/main-figure0" "main"' ========
runsystem(xelatex -halt-on-error -interaction=batchmode -jobname "cache/main-fi
gure0" "main")...disabled (restricted).

\openout3 = `main.auxlock'.


! Package tikz Error: Sorry, the system call 'xelatex -halt-on-error -interacti
on=batchmode -jobname "cache/main-figure0" "main"' did NOT result in a usable o
utput file 'cache/main-figure0' (expected one of .pdf:.jpg:.jpeg:.png:.bmp:). P
lease verify that you have enabled system calls. For pdflatex, this is 'pdflate
x -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 'cache/main
-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.34         \end{tikzpicture}
                              
This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.


Overfull \hbox (127.35689pt too wide) in paragraph at lines 17--35
[][] 
 []


LaTeX Warning: Reference `plot:graphs' on page 1 undefined on input line 39.

[1

] (main.aux)

LaTeX Warning: There were undefined references.


LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 ) 

此错误仅发生在具有 TikZ 和 PGFPlot 资源的子文件中。\ref即使它输出为 pdf,它也会破坏我的整个文档。任何帮助都将不胜感激。

答案1

评论太长了


您只需加载两个external库中的一个。目前,TikZ v3.1.9a 和 PGFPlots v1.18.1 的版本应该相同,因此这只是个人喜好问题。

当我编译时

% used PGFPlots v1.18.1
\documentclass[border=5pt,varwidth]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{
        groupplots,
        external,
    }
    \tikzexternalize[prefix=cache/]
\begin{document}
\begin{tikzpicture}
    \begin{groupplot}[
        group style={
            group size=2 by 1,
            horizontal sep=40pt,
            vertical sep=20pt,
        },
        xlabel=B,
        ylabel=s,
    ]
    \nextgroupplot
        \addplot {x};
    \nextgroupplot
        \addplot {x^3};
    \end{groupplot}
\end{tikzpicture}
\end{document}

使用最新的 MiKTeX 中的 LuaLaTeX,我可以从日志中看到\tikzexternal调用

===== 'mode=convert with system call': Invoking 'lualatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "cache/minimal-figure0" "\def\tikzexter
nalrealjob{minimal}\input{minimal}"' ========

其工作正常,即我没有收到任何错误消息。

关于\ref。这里不清楚你的意思。要么你想让它返回一个数字,但为此figure缺少环境。或者你想让它返回图,但为此你必须将移动到命令\label后面\addplot。之后你需要编译三次才能看到预期的结果,因为在第一次运行中环境axis被外部化并且\label被写入 AUX 文件,在第二次运行中 crossref 被外部化然后在第三次运行后显示出来。

相关内容