0

Hello there

Currently trying to implement tikz's external library to a file named stack q.tex

MWE:

\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}

The compilation never completes, its stuck in the creation of figure_0.0.aux with the following message being display in the terminal:

This is LuaHBTeX, Version 1.13.2 (TeX Live 2021) 
 system commands enabled.
tput: No value for $TERM and no -T specified
Felipe9
  • 309
  • 1
    Why it is important to you to use spaces in filenames? Why not hyphen instead? – Simon Dispa Jan 22 '22 at 21:51
  • I echo Simon's comment. You will have problems with different (older) software (not just LaTeX and friends) when you try to use spaces in filenames. Just use _ or -. – Dr. Manuel Kuehner Jan 23 '22 at 00:39
  • When you have many files its handy to use a name scheme ex. [group] - [kind] [index].[ext], having _ instead of spaces eliminates the possibility to search trough many files, which is troublesome. – Felipe9 Jan 23 '22 at 13:50
  • 1
    try to quote the name --jobname "\image" "\subfilename" . But Simon is right: you can spent a lot time debugging problems with unquoted or wrongly quoted file names if they contain spaces. I never use them (which is why I had no problems with your example in your last question ...). I don't understand your remark about searching. Wildcards don't require spaces. – Ulrike Fischer Jan 23 '22 at 16:20
  • Sorry Ulrike, adding the quotes does not work, nor any combination of quotes (with/without) in the \newcommand\subfilename{"*.tex"} and --jobname "\image" "\subfilename" – Felipe9 Jan 24 '22 at 15:22
  • Without spaces the whole file name is treated as a single word, confusing search engines whenever you want to search based on keywords inside file names, even tho latex generated pdfs can have custom keywords, thanks to hyperref, other files such as excel, scripts and codes don't, and having different name schemes would be a real mess, as many interact with each other. – Felipe9 Jan 24 '22 at 15:28

1 Answers1

1

Even when space is not a prohibited character in filenames, the experience of several commenters recommends staying on the safe side and avoiding using it to save debugging time. You experienced it firsthand in your last question.

Coming back to your question, since you already have a naming scheme for filenames and would like to easily locate a figure generated by externalize, use \tikzsetnextfilename{<my-naming-scheme>} before the tikz image (without spaces!) to set the filename of the figure created.

In the next example, with two sections, \tikzsetnextfilename{FIG_section_\thesection_paraboloid} was used for the first and \tikzsetnextfilename{FIG_section_\thesection_convex} for the second.

After compiling (stackq.tex) the output is

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}

Simon Dispa
  • 39,141
  • Thanks for suggesting the change in the nextfilename but the problem is not to localise each figure, but to find files in a big archive, that is the main .tex file as well as its subfiles and several other different projects from which some interact with each other. Having not only all .tex files and directories and other related files restricted to use _ has a big impact in the organisation and "search-ability". – Felipe9 Jan 23 '22 at 19:39
  • +1 @DJ9 I do not understand your comment about the "searchability", see also Ulrike's last comment below your question. – Dr. Manuel Kuehner Jan 23 '22 at 21:19