Open JasonGross opened 2 months ago
The problem here is that pgf expects the lines to be preserved. The problem is that LaTeX gives us 2 options to parse the inputs:
%
are removed…)The solution here is to use CacheMeCode
instead of CacheMe
(used internally by tikz
), which uses the verbatim mode. This can be done by replacing
\begin{tikzpicture}
…
\end{tikzpicture}
with
\begin{CacheMeCode}{tikzpicture}
\end{CacheMeCode}
like in:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{robust-externalize}
\cacheTikz
\robExtConfigure{
add to preset={tikz}{
add to preamble={
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
}
},
}
\begin{document}
\begin{CacheMeCode}{tikzpicture}
\begin{axis}
\addplot [semithick, black]
table {%
0 0
0.0752933174371719 0.0355731099843979
};
\end{axis}
\end{CacheMeCode}
\end{document}
You can also choose a different name like:
\NewDocumentEnvironment{tikzpictureVerb}{}{\CacheMeCode{tikzpicture}}{\endCacheMeCode}
or replace the existing tikzpicture
environment with the verbatim version (warning: not sure if it can have some side effects):
\RenewDocumentEnvironment{tikzpicture}{}{\CacheMeCode{tikzpicture}}{\endCacheMeCode}
MWE:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{robust-externalize}
\cacheTikz
\robExtConfigure{
add to preset={tikz}{
add to preamble={
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
}
},
}
%% Create a new env
\NewDocumentEnvironment{tikzpictureVerb}{}{\CacheMeCode{tikzpicture}}{\endCacheMeCode}
%% Replace existing env
\RenewDocumentEnvironment{tikzpicture}{}{\CacheMeCode{tikzpicture}}{\endCacheMeCode}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot [semithick, black]
table {%
0 0
0.0752933174371719 0.0355731099843979
};
\end{axis}
\end{tikzpicture}
\end{document}
If you find this solution good enough for your need, we can close this.
In any case, I'll let this issue open until I document this behavior, and I'd like to try to fix https://tex.stackexchange.com/questions/718003/alias-of-verbatim-environment-with-optional-arguments
Parallel to https://github.com/sasozivanovic/memoize/issues/19 This code only works if I comment out
\cacheTikz
Otherwise it errors with