tikzlibrary:带有空格的外部文件名问题

tikzlibrary:带有空格的外部文件名问题

你好呀

当前尝试将库实现tikzexternal名为stack q.tex

梅威瑟:

\newcommand\subfilename{"./stack q.tex"}
\documentclass{article}

% pgfplots
\usepackage{pgfplots}

% uncommenting generates error
\usetikzlibrary{external}
% External lib
\tikzexternalize[
    up to date check={simple},
    prefix=./.build/figures/
] % turn externalization on/off
\tikzsetfigurename{figure_\arabic{part}.} % set figure names

% Using tikzset generates error
\tikzset{%
    external/system call={%
        lualatex \tikzexternalcheckshellescape
        --halt-on-error
        --shell-escape
        --interaction=batchmode
        --jobname "\image" \subfilename
    }
}

\pgfplotsset{
    compat  = newest,
    width   = 10cm,    % width
    height  =  7cm,    % height
    samples = 10,
}

\begin{document}

% \tikzsetfigurename{figure_\arabic{part}.} % set figure names

\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        \addplot3 [
            % Aparence
            surf,
            opacity=0.5,
            fill opacity= 1,
            faceted color = white,
            shader=faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            domain   = -1:1,
            domain y = -1:1,
        ]{
            x^2-y^2
        };
    
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        \addplot3 [
            % Aparence
            surf,
            opacity=0.5,
            fill opacity= 1,
            faceted color = white,
            shader=faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            variable   = u,
            variable y = v,
            domain   = 0:360,
            domain y = -180:0,
        ]
        (
            {cos(u)*sin(v)}, 
            {sin(u)*sin(v)}, 
            {cos(v)}
        );
    
    \end{axis}
\end{tikzpicture}

\end{document}

编译从未完成,它停留在创建状态,figure_0.0.aux并在终端中显示以下消息:

This is LuaHBTeX, Version 1.13.2 (TeX Live 2021) 
 system commands enabled.
tput: No value for $TERM and no -T specified

答案1

即使空格不是文件名中的禁用字符,一些评论者的经验也建议保持安全并避免使用它以节省调试时间。你在上一个问题中亲身体验过这一点。

回到你的问题,因为你已经有了文件名的命名方案,并且想要轻松找到由 externalize 生成的图形,请\tikzsetnextfilename{<my-naming-scheme>}在 tikz 图像之前使用(不带空格!)来设置所创建图形的文件名。

在下一个示例中,有两个部分,\tikzsetnextfilename{FIG_section_\thesection_paraboloid}用于第一部分,\tikzsetnextfilename{FIG_section_\thesection_convex}用于第二部分。

编译(stackq.tex)后输出为

F

%%  file stackq.tex

\documentclass{article}

% pgfplots
\usepackage{pgfplots}

% uncommenting generates error
\usetikzlibrary{external}
% External lib
\tikzexternalize[
    up to date check={simple},
    prefix=./figures/
] % turn externalization on/off

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


\pgfplotsset{
    compat  = newest,
    width   = 10cm,    % width
    height  =  7cm,    % height
    samples = 10,
}

\begin{document}
    
\section{First} 
    
\tikzsetnextfilename{FIG_section_\thesection_paraboloid}% added <<<<<<<<<<<<<<<<<<<<<<
\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        \addplot3 [
            % Aparence
            surf,
            opacity=0.5,
            fill opacity= 1,
            faceted color = white,
            shader=faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            domain   = -1:1,
            domain y = -1:1,
        ]{
            x^2-y^2
        };
    
    \end{axis}
\end{tikzpicture}

\section{Second}

\tikzsetnextfilename{FIG_section_\thesection_convex}% added <<<<<<<<<<<<<<<<<<<<<<
\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        \addplot3 [
            % Aparence
            surf,
            opacity=0.5,
            fill opacity= 1,
            faceted color = white,
            shader=faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            variable   = u,
            variable y = v,
            domain   = 0:360,
            domain y = -180:0,
        ]
        (
            {cos(u)*sin(v)}, 
            {sin(u)*sin(v)}, 
            {cos(v)}
        );
    
    \end{axis}
\end{tikzpicture}

\end{document}

相关内容