Is there a way to create several numbered variables (like \x1, \x2,..
) in a loop?
BTW: I do not need to use \usetikzlibrary{math}
if there is solution without the math
-library.
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\foreach \N in {1,...,5}{%%
\pgfmathsetmacro\tmp{random(1,52)} Test: \tmp ~
%
\tikzmath{\x\N = \tmp;} % Does not work
\tikzset{ declare function={ x(\N) = \tmp; }, } % Does not work
}%%
\section{Does not work}
%\pgfmathprint{\x3} % Does not work
%\pgfmathprint{x(3)} % Does not work
\end{document}
\foreach
loop will be local to it and will be forgotten after it. Either use the for loop of tikzmath, the.list
handler or a different loop implementation. Thedeclare function
won't work either because PGFMath would only overwrite eachx(\N)
function (and\tmp
would also only hold the last definition). Is there a use case for this?