1

Hello there

Currently trying to implement the external library but cant seem to make it work

\documentclass{article}

% pgfplots \usepackage{pgfplots}

% % Uncommenting generates error % \usetikzlibrary{external} % % External lib % \tikzexternalize % turn externalization on/off % \tikzsetfigurename{./figures/figure_\arabic{part}.} % set names

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

\begin{document} \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}

Uncommenting external library code generates the following error:

Package tikz Error: Sorry, the system call 'lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "./figures/figure_0.1" "\def\tikzexternalrealjob{"stack q"}\input{"stack q"}"' did NOT result in a usable output file './figures/figure_0.1' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -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 './figures/figure_0.1.log'. If you continue now, I'll try to typeset the picture.

Notes:

  • ./figures/figure_0.1.log was never written, it might seem that there is problem with writing some file, but it isnt the case as files with .md5 have been created.
  • Compilation call is: lualatex --synctex=1 --shell-escape --output-dir=.build --interaction=nonstopmode --file-line-error %DOC%

List of .build directory files: enter image description here


Update 1

Changes:

  • Fix directory to include .build/
  • Added tikzset external/system call command
\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 names

% Using tikzset returns 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}

% \tikzsetfigurename{figure_\arabic{part}.} % set 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}

Notes:

  • Now its possible to see the .log generated files. they all disclaim the same message
...
! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ...

l.13 \tikzsetfigurename {figure_\arabic{part}.} % set names ...

Displacing \tikzsetfigurename to after \begin{document} has no effect.

  • removing --output-directory option from compilation call and replacing external related commands with:
% uncommenting generates error
\usetikzlibrary{external}
% External lib
\tikzexternalize[
    up to date check={simple},
    prefix=./figures/
] % turn externalization on/off
\tikzsetfigurename{figure_\arabic{part}.} % set figure names

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

Still generates the same error as before.


Conclusion

Turns out the problem is that the main file has spaces in the name, creating a new question to address this issue here.

Here is the current working MWE renamed to stackq.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" "\texsource" } }

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

Felipe9
  • 309

1 Answers1

1

I will share my setup. (windows, TeXstudio, MiKTeX)

(0) No spaces in the filename! Use stackq.tex

(1) Using lualatex.exe -synctex=1 -interaction=nonstopmode -shell-escape %.tex

(2) TestExternalize.tex in the working directory EXTERNALIZE with a subdirectory FIGURES

c

%%% File TestExternalize.tex

\documentclass{article}

% pgfplots \usepackage{pgfplots} \pgfplotsset{compat=newest}

% % Uncommenting does not generates error \usetikzlibrary{external}

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

\tikzset{external/system call={% added <<<<<<<<<<<<<< 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} \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}

(3) Directory structure after compiling.

A

(4) Output TestExternalize.pdf

b

(5) When compiling a second time (faster) the following messages appear

===== Image './FIGURES/TestExternalize-figure0' is up-to-date. ======
===== Image './FIGURES/TestExternalize-figure1' is up-to-date. ======
Simon Dispa
  • 39,141
  • +1: Out of curiosity, did you ever implemented a functionality that names the external files according to the figure caption in the document? For example "Figure3-2.pdf". – Dr. Manuel Kuehner Jan 22 '22 at 18:18
  • That would actually be great, using this i could instead of modifying the figure filenames to include part and other divisions i could set it as it is in the document, unfortunately i dont know how to do that – Felipe9 Jan 22 '22 at 18:33
  • @DJ9 Did you try my procedure in your system? It works and answer your question? – Simon Dispa Jan 22 '22 at 18:41
  • Sorry @Simon, the compilation still ends failing. Ive tried not using the output-directory option in the procedure as well, still fails. – Felipe9 Jan 22 '22 at 18:55
  • 1
    @ Dr. Manuel Kuehner In a book I used \tikzsetnextfilename{..} to set the filename, like \tikzsetnextfilename{Chap05/FIGURES/Ch05fig03} \begin{figure} \input{Chap05/Ch05-modelSgalaxies.tikz} \caption{Regression model of S galaxies.} \label{fig:modelSgalaxies} \end{figure}. – Simon Dispa Jan 22 '22 at 19:22