I am trying to create a document class with random style attributes, determined at compilation time. Random attributes would ideally include:
- Margins
- Line spacing
- Font selection
For my particular use case, in-document references are not typically useful/a design constraint, so there's no first-order need to worry about layout being consistent across compilations.
I attempted to use \pgfmathrandomitem
in a new .cls
file, as follows:
% randocls.cls
\LoadClass{article}
\usepackage{pgffor}
\pgfmathdeclarerandomlist{marginmargins}{{0.0}{0.25}{0.5}{0.75}}
\pgfmathrandomitem{\marginns}{marginmargins}
% none of the following work...
% (the implied margins are different; this is MWE so nbd)
% Case 1:
\usepackage[margin={\marginns}in]{geometry}
% Case 2:
% \addtolength{\topmargin}{{\marginns}in}
% Case 3:
% \let\rmarginns{\marginns}
% \addtolength{\topmargin}{{\rmarginns}in}
Under Case 1:
("C:\Program Files\MiKTeX 2.9\tex/latex/geometry\geometry.cfg")
! Missing number, treated as zero.
<to be read again>
{
l.1007 \ProcessOptionsKV[p]{Gm}
%
Under Case 2:
! Missing number, treated as zero.
<to be read again>
{
l.23 \addtolength{\topmargin}{{\marginns}in}
Under Case 3:
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.30 \let\rmarginns{\marginns
}
My best guess is that the problem relates to when pgfmathrandomitem
can actually yield a random item, but I am in over my head. Is there a way to work around this, or another randomization mechanism that will allow randomization in the document header?