I am trying to create a mental math practice sheet generator in a latex editor. For the number of questions intended, I require only half of A4 sheet. So the other half I want to print the same set of questions for another student.
In excel we can simply copy the values of a cell into another to duplicate. How do I duplicate all the questions containing randomly generated numbers.
I have the syntax for the questions. Just need help with duplicating part. Thanks.
\tikzset{declare function={randomfixed(\a,\b) = int(random(0,int(\b-\a))+\a);}}
% get random integer
\newcommand\randomint[2]{\bgroup%
\pgfmathsetmacro\myval{randomfixed(#1,#2)}%
\pgfmathsetmacro\final{(\myval < 0)?"(\myval)":\myval}%
\final\egroup%
}
\newcommand{\randnzi}{%random non-zero integer, change random (argument) to increase or decreases range
\pgfmathsetmacro{\a}{int(ifthenelse(rand > 0, 1, -1)*random(1,9))}%
}
% get random integer for equation - the only diff from \randomint is that this one doesn't generate () for negative numbers
\newcommand\randomeqint[2]{\bgroup%
\pgfmathsetmacro\myval{randomfixed(#1,#2)}%
\pgfmathsetmacro\final{(\myval < 0)?"\myval":\myval}%
\final\egroup%
}
% get random operator
\def\ops{{"+","-","\times","/"}}
\def\pmop{{"+","-"}}
\newcommand\randomop{\bgroup\pgfmathsetmacro\op{\ops[int(rnd*4)]}\op\egroup}
%get random + or - only
\newcommand\randompm{{\bgroup\pgfmathsetmacro\op{\pmop[int(rnd*2)]}\op\egroup}}
% choose random seed
\pgfmathsetseed{\pdfuniformdeviate 10000000}
\begin{document}
\foreach \n in {1,...,5}{
$\randomint{-10}{10} \randomop{} \randomint{-10}{10} = $\par
%\par is used in for loop to create a linebreak after each iteration
}


\letor\edefwhich are not described usually in LaTeX books. But this is what is needed here simply to store once and for all a given random seed in a "macro" and use it after, see my answer. – Jan 14 '19 at 17:04