Closed cfr42 closed 1 month ago
The problem seems to be that the Lua functions min
and max
do only handle the first two arguments, see
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain=0:3,
samples=4,
]
\addplot {min(1,x)};
\addplot {min(1,2,x)};
% \addplot {min(1,min(2,x))}; % <-- workaround
% \addplot {max(2,x)};
% \addplot {max(1,2,x)};
\end{axis}
\end{tikzpicture}
\end{document}
(I did not test other functions that might show the current bug.)
So what changed in 1.12? Did pgfplots or pgf switch to using the Lua functions?
Sorry. I don't use pgfplots
very much and I probably shouldn't be submitting anything on GitHub. But does that mean the bug is in the lua backend and should be reported elsewhere, that it isn't considered a bug or neither?
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
% Workaround for https://github.com/pgf-tikz/pgfplots/issues/492
\directlua{
pgfluamathfunctions.stringToFunctionMap["max"] = math.max
pgfluamathfunctions.stringToFunctionMap["min"] = math.min
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:3, samples=4]
\addplot {min(1,x)};
\addplot {min(1,2,x)};
\end{axis}
\end{tikzpicture}
\end{document}
Awesome. Your (@hmenke) workaround as well as the fix work perfectly fine.
Thank you for fixing this so rapidly.
Ref. https://tex.stackexchange.com/q/726281/ and https://tex.stackexchange.com/a/726304/
The example from Jasper's question renders incorrectly if compiled with LuaTeX if
compat=1.18
. Experimentation shows the cutoff is between1.11
and1.12
as demonstrated by the example below. Compiled as-is, the image is only partially rendered. If the currentcompat
line is commented and the one below uncommented, the output is correct.This appears to be engine-specific as the regression does not affect pdfTeX.
compat=1.18
renders the image completely on this engine.