leo-colisson / robust-externalize

A LaTeX library to cache pictures (including tikz, python code, and more) in a robust, customizable, and pure way.
7 stars 2 forks source link

cache tikz not working in \robExtConfigure #14

Closed dflvunoooooo closed 7 months ago

dflvunoooooo commented 7 months ago

If I run code in a CacheMeCode environment and want to cache the generated tikz file as well, this is working perfektly with the \cacheTikz command. But if I set the option in the \robExtConfigure option, it is not applied. Here is my document:

\documentclass{scrreport}

\usepackage{robust-externalize}
\setPlaceholder*{__ROBEXT_LATEX_ENGINE__}{xelatex}  % Für das robustExternalize-Paket.
\runHereAndInPreambleOfCachedFiles{
    \usepackage{fontspec}
    \usepackage{gnuplot-lua-tikz}           
}
\robExtConfigure{
    tikz terminal/.append style={
        cache tikz,
    }
}

%\setmainfont{TeX Gyre Adventor}        

\begin{document}

This is a text to show the applied font.

\begin{figure}
    \begin{CacheMeCode}{gnuplot, tikz terminal={size 8cm,5cm}}
        set xlabel "Bla bla test test"
        plot cos(x)
    \end{CacheMeCode}
\end{figure}

\end{document}

If one does run this with the setmainfont commented out, the standard font is applied. If in the second step this option is activated and the file compiled again, the font will be applied to the figure too, as can be seen in the x label. If one does this step without the \robExtConfigure option and instead with the \cacheTikz option, The font change for the second compilation is not applied to the x label in the figure.

tobiasBora commented 7 months ago

Oh good catch, thanks, this is because I made a mistake in the documentation: tikz terminal is created/reset every time we call the gnuplot style, so we need to modify it inside the gnuplot preset, like:

\documentclass{scrreport}

\usepackage{robust-externalize}
\setPlaceholder*{__ROBEXT_LATEX_ENGINE__}{xelatex}  % Für das robustExternalize-Paket.
\runHereAndInPreambleOfCachedFiles{
    \usepackage{fontspec}
    \usepackage{gnuplot-lua-tikz}           
}
\robExtConfigure{
  add to preset={gnuplot}{
    tikz terminal/.append style={
      cache tikz,
    }
  }
}

\setmainfont{TeX Gyre Adventor}     

\begin{document}

This is a text to show the applied font.

\begin{figure}
    \begin{CacheMeCode}{gnuplot, tikz terminal={size 8cm,5cm}}
        set xlabel "Bla bla test test"
        plot cos(x)
    \end{CacheMeCode}
\end{figure}

\end{document}

The doc is now up to date.