\usetikzlibrary{external} 不起作用

\usetikzlibrary{external} 不起作用

我正在尝试编译一个包含多个图的 tex 文件。根据 Overleaf 的说法,通过“外部化”这些图可以显著减少编译时间。(这是我使用的代码的摘录):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{fourier}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{colortbl}
\usepackage[dvipsnames]{xcolor}
\usepackage{float}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{icomma}
\usepackage{enumerate}
\usepackage{url}
\usepackage{gensymb}
\usepackage{fancyhdr}
\usepackage{sectsty}
\usepackage{multicol}
\usepackage{pgfplots}

\geometry{
 left=20mm,
 right=20mm,
}
\pgfplotsset{width=7cm,compat=1.9}
\usetikzlibrary{external}
\tikzexternalize[prefix=Figures/]
\decimalpoint
\setlength{\columnseprule}{0.1pt}
\def\columnseprulecolor{\color{gray}}
\setlength{\columnsep}{0.5cm}
\setlength{\parskip}{1em}
\sectionfont{\centering\huge\color{MidnightBlue}}

\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\newcommand{\iu}{{i\mkern-2mu}}
\newcommand{\Arg}{\text{Arg}\mkern2mu}
\newcommand{\Log}{\text{Log}\mkern2mu}

\begin{document}
\title{\color{NavyBlue}\Huge\textbf{Title}}
\date{\today}
\author{--}
\maketitle

\begin{figure}[H]
    \centering
    \begin{tikzpicture}
        \centering
        \begin{axis}[
            colormap/cool
        ]
        \addplot3[
            surf,
        ]
        {x};
        \addlegendentry{$\Re{f(z)}=x$}
        \end{axis}
    \end{tikzpicture}
\end{figure}


\end{document}

文件夹 Figures 确实存在,但是每次我使用 pdftex 进行编译时,都会出现以下错误:

 Sorry, the system call 'pdflatex -halt-on-error
-interaction=batchmode -jobname "Figures/main-figure0" "\def\tikzexternalrealjob{main}\input{main}"' did NOT result in a usable output file

我不知道是否有问题,我将非常感谢您的帮助。

提前致谢!

答案1

尝试这个设置。

\usetikzlibrary{external}
\tikzexternalize[%
up to date check={simple},
prefix=./Figures/]% Folder needs to be created before compiling

\tikzset{external/system call={%
        pdflatex \tikzexternalcheckshellescape
        -halt-on-error -shell-escape -interaction=batchmode
        -jobname "\image" "\texsource"}}

从工作目录中的命令提示符

pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %filename%.tex

第二次的输出比预期的要快得多。

A

% !TeX TS-program = pdflatex

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{fourier}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{colortbl}
\usepackage[dvipsnames]{xcolor}
\usepackage{float}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{icomma}
\usepackage{enumerate}
\usepackage{url}
\usepackage{gensymb}
\usepackage{fancyhdr}
\usepackage{sectsty}
\usepackage{multicol}
\usepackage{pgfplots}

\geometry{
    left=20mm,
    right=20mm,
}
\pgfplotsset{width=7cm,compat=1.9}

% ********************************************************** <<<<<<<<<<<<<<<<<<<<<<
\usetikzlibrary{external}
\tikzexternalize[%
up to date check={simple},
prefix=./Figures/]% Folder needs to be created before compiling

\tikzset{external/system call={%
        pdflatex \tikzexternalcheckshellescape
        -halt-on-error -shell-escape -interaction=batchmode
        -jobname "\image" "\texsource"}}
% **********************************************************


\decimalpoint
\setlength{\columnseprule}{0.1pt}
\def\columnseprulecolor{\color{gray}}
\setlength{\columnsep}{0.5cm}
\setlength{\parskip}{1em}
\sectionfont{\centering\huge\color{MidnightBlue}}

\newcommand{\HRule}[1]{\rule{\linewidth}{#1}}
\newcommand{\iu}{{i\mkern-2mu}}
\newcommand{\Arg}{\text{Arg}\mkern2mu}
\newcommand{\Log}{\text{Log}\mkern2mu}

\begin{document}
    \title{\color{NavyBlue}\Huge\textbf{Title}}
    \date{\today}
    \author{--}
    \maketitle
    
    \begin{figure}[H]
        \centering
        \begin{tikzpicture}
            \centering
            \begin{axis}[
                colormap/cool
                ]
                \addplot3[
                surf,
                ]
                {x};
                \addlegendentry{$\Re{f(z)}=x$}
            \end{axis}
        \end{tikzpicture}
    \end{figure}
        
\end{document}

相关内容