summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/counterz/counterz.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/counterz/counterz.dtx')
-rw-r--r--macros/latex/contrib/counterz/counterz.dtx200
1 files changed, 92 insertions, 108 deletions
diff --git a/macros/latex/contrib/counterz/counterz.dtx b/macros/latex/contrib/counterz/counterz.dtx
index 2efbfa056d..20cf2cf08d 100644
--- a/macros/latex/contrib/counterz/counterz.dtx
+++ b/macros/latex/contrib/counterz/counterz.dtx
@@ -7,7 +7,7 @@
%<*readme>
----------------------------------------------------------------------
-`counterz' --- 2023/05/30 Version 1.1.0
+`counterz' --- 2023/06/05 Version 1.1.1
Copyright (C) 2023 by Christopher McClain
E-mail: christopher.mcclain@mail.wvu.edu
@@ -38,7 +38,7 @@ random counters and save such counter values for future typesetting.
\preamble
----------------------------------------------------------------------
-`counterz' --- 2023/05/30 Version 1.1.0 Additional tools for counters
+`counterz' --- 2023/06/05 Version 1.1.1 Additional tools for counters
E-mail: christopher.mcclain@mail.wvu.edu
Released under the LaTeX Project Public License v1.3c or later
See https://www.latex-project.org/lppl.txt
@@ -138,6 +138,7 @@ and the derived files counterz.ins,
%
%\changes{v1.0.0}{2023/05/19}{First public release}
%\changes{v1.1.0}{2023/05/30}{New and revised commands and error reports}
+%\changes{v1.1.1}{2023/06/05}{Bug fixes}
%
%
%\begin{abstract}
@@ -148,9 +149,7 @@ and the derived files counterz.ins,
% random counters and save such counter values for future typesetting.
%\end{abstract}
%
-%\begin{multicols}{2}
-% \tableofcontents
-%\end{multicols}
+%\tableofcontents
%
%\section{Introduction}
%
@@ -687,7 +686,18 @@ and the derived files counterz.ins,
%
%\subsection{Random Counters}
%
-% We first define random versions of \cs{setcounter} and \cs{addtocounter}.
+% In order to effectively manage the options of randomizing counter values or
+%\DescribeMacro{\randomizectr}
+% reusing counter values, the commands \cs{randomizectr} and \cs{norandomizectr}
+% are used to toggle an internal boolean variable. The internal boolean
+%\DescribeMacro{\norandomizectr}
+% is initialized as TRUE when the \textsf{counterz} package is loaded. A
+% conditional command \cs{ifrandomizectr}\marg{foo}\marg{bar} executes
+%\DescribeMacro{\ifrandomizectr}
+% \meta{foo} when the boolean is TRUE and otherwise executes \meta{bar}.
+%
+% We next define random versions of \cs{setcounter} and \cs{addtocounter}.
+% These commands will only execute when the document is set to randomize.
% The command \cs{randsetcounter}\marg{counter}\marg{min}\marg{max} assigns
%\DescribeMacro{\randsetcounter}
% to \meta{counter} a random integer value between \meta{min} and \meta{max}.
@@ -699,10 +709,11 @@ and the derived files counterz.ins,
% \meta{counter} a random integer value between \meta{min} and \meta{max}.
%\DescribeMacro{\xrandaddtocounter}
% \cs{xrandaddtocounter} is a prefix version of \cs{randaddtocounter}.
-% The following code may be used to produce an expression in the form
-% $ax+b$, where $a$ and $b$ are random integers between $-10$ and $10$:
+% The following code produces an expression in the form $ax+b$, where $a$
+% and $b$ are random integers between $-10$ and $10$:
%
%\begin{verbatim}
+%\randomizectr
%\xprovidecounter{a}
%\xprovidecounter{b}
%\xrandsetcounter{a}{-10}{10}
@@ -711,17 +722,14 @@ and the derived files counterz.ins,
%\end{verbatim}
%
% \noindent
-% Organized in the following table are sixty instances of output that are
+% Organized in the following table are fifty instances of output that are
% randomly generated by the typesetting of this document:
%
% \bigskip
%\noindent
%\xprovidecounter{a}
%\xprovidecounter{b}
-%\begin{tabular}{rrrrrr}
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
+%\begin{tabular}{rrrrr}
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
@@ -751,9 +759,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -769,9 +774,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -787,9 +789,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -805,9 +804,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -823,9 +819,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -841,9 +834,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -859,9 +849,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -877,9 +864,6 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
@@ -895,23 +879,10 @@ and the derived files counterz.ins,
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
%\xrandsetcounter{a}{-10}{10}
%\xrandsetcounter{b}{-10}{10}
-%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ &
-%\xrandsetcounter{a}{-10}{10}
-%\xrandsetcounter{b}{-10}{10}
%$\xcoef{a}\ifctrzero{a}{\xarabic{b}}{x \xsignednz{b}}$ \\
%\end{tabular}
%
% \bigskip
-% In order to effectively manage the options of randomizing counter values or
-%\DescribeMacro{\randomizectr}
-% reusing counter values, the commands \cs{randomizectr} and \cs{norandomizectr}
-% are used to toggle an internal boolean variable. The internal boolean
-%\DescribeMacro{\norandomizectr}
-% is initialized as TRUE when the \textsf{counterz} package is loaded. A
-% conditional command \cs{ifrandomizectr}\marg{foo}\marg{bar} executes
-%\DescribeMacro{\ifrandomizectr}
-% \meta{foo} when the boolean is true and otherwise executes \meta{bar}.
-%
% If our document contains randomly generated counters, but we wish to typeset
% the document again without changing those values, then we need a way to save
%\DescribeMacro{\opencountersfile}
@@ -1067,7 +1038,7 @@ and the derived files counterz.ins,
% \begin{macrocode}
%<*package>
\ProvidesPackage{counterz}[%
- 2023/05/30 v1.1.0 Additional tools for counters
+ 2023/06/05 v1.1.1 Additional tools for counters
]%
\RequirePackage{etoolbox,makecmds}
% \end{macrocode}
@@ -1503,60 +1474,6 @@ and the derived files counterz.ins,
%
%\subsection{Random Counters}
%
-% The commands \cs{randsetcounter} and \cs{randaddtocounter} use the pdf\TeX\
-% primitive \cs{pdfuniformdeviate} to provide random versions of
-% \cs{setcounter} and \cs{addtocounter}. The commands \cs{xrandsetcounter} and
-% \cs{xrandaddtocounter} are prefix versions of \cs{randsetcounter} and
-% \cs{randaddtocounter}, respectively.
-%
-%\begin{macro}{\randsetcounter}
-%\changes{v1.1.0}{2023/05/30}{new}
-%\begin{macro}{\xrandsetcounter}
-%\changes{v1.1.0}{2023/05/30}{now based on a new \cs{randsetcounter}}
-%
-% \cs{randsetcounter}\marg{counter}\marg{min}\marg{max} assigns to
-% \meta{counter} a random integer value between \meta{min} and \meta{max}.
-%
-% \begin{macrocode}
-\newcommand{\randsetcounter}[3]{%
- \setcounter{#1}{%
- \the \numexpr #2+\pdfuniformdeviate \numexpr #3-#2+1 \relax
- }%
-}%
-\newcommand{\xrandsetcounter}[3]{%
- \randsetcounter{\@counterz@counterprefix#1}{#2}{#3}
-}%
-% \end{macrocode}
-%
-%\end{macro}
-%\end{macro}
-%
-%\begin{macro}{\randaddtocounter}
-%\changes{v1.1.0}{2023/05/30}{new}
-%\begin{macro}{\xrandaddtocounter}
-%\changes{v1.1.0}{2023/05/30}{now based on a new \cs{randaddtocounter}}
-%
-% \cs{randaddtocounter}\marg{counter}\marg{min}\marg{max} adds to \meta{counter}
-% a random integer value between \meta{min} and \meta{max}.
-%
-% \begin{macrocode}
-\newcommand{\randaddtocounter}[3]{%
- \addtocounter{#1}{%
- \the \numexpr #2+\pdfuniformdeviate \numexpr #3-#2+1 \relax
- }%
-}%
-\newcommand{\xrandaddtocounter}[3]{%
- \randaddtocounter{\@counterz@counterprefix#1}{#2}{#3}
-}%
-% \end{macrocode}
-%
-%\end{macro}
-%\end{macro}
-% The following commands are designed to provide a means by which authors can
-% generate random values for counters but also preserve those values for future
-% typesettings. This is accomplished by storing counters and their values in an
-% external file and then inputting the file before a subsequent typesetting.
-%
%\begin{macro}{\randomizectr}
%\begin{macro}{\norandomizectr}
%
@@ -1579,7 +1496,7 @@ and the derived files counterz.ins,
%\begin{macro}{\ifrandomizectr}
%
% \cs{ifrandomizectr}\marg{foo}\marg{bar} executes \meta{foo} if the boolean
-% \textit{@counterz@random} is true and otherwise executes \meta{bar}.
+% \textit{@counterz@random} is TRUE and otherwise executes \meta{bar}.
%
% \begin{macrocode}
\newcommand{\ifrandomizectr}[2]{%
@@ -1611,6 +1528,73 @@ and the derived files counterz.ins,
%
%\end{macro}
%
+% The commands \cs{randsetcounter} and \cs{randaddtocounter} use the pdf\TeX\
+% primitive \cs{pdfuniformdeviate} to provide random versions of
+% \cs{setcounter} and \cs{addtocounter}. The commands \cs{xrandsetcounter} and
+% \cs{xrandaddtocounter} are prefix versions of \cs{randsetcounter} and
+% \cs{randaddtocounter}, respectively. Each of these four commands will generate
+% random counter values only when the boolean \textit{@counterz@random} is TRUE.
+%
+%\begin{macro}{\randsetcounter}
+%\changes{v1.1.0}{2023/05/30}{new}
+%\changes{v1.1.1}{2023/06/05}{bug fix}
+%\begin{macro}{\xrandsetcounter}
+%\changes{v1.1.0}{2023/05/30}{now based on a new \cs{randsetcounter}}
+%
+% \cs{randsetcounter}\marg{counter}\marg{min}\marg{max} assigns to
+% \meta{counter} a random integer value between \meta{min} and \meta{max},
+% if \textit{@counterz@random} is TRUE.
+%
+% \begin{macrocode}
+\newcommand{\randsetcounter}[3]{%
+ \ifrandomizectr{%
+ \setcounter{#1}{%
+ \the \numexpr #2+\pdfuniformdeviate \numexpr #3-#2+1 \relax
+ }%
+ }{%
+ % Do Nothing
+ }%
+}%
+\newcommand{\xrandsetcounter}[3]{%
+ \randsetcounter{\@counterz@counterprefix#1}{#2}{#3}
+}%
+% \end{macrocode}
+%
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\randaddtocounter}
+%\changes{v1.1.0}{2023/05/30}{new}
+%\changes{v1.1.1}{2023/06/05}{bug fix}
+%\begin{macro}{\xrandaddtocounter}
+%\changes{v1.1.0}{2023/05/30}{now based on a new \cs{randaddtocounter}}
+%
+% \cs{randaddtocounter}\marg{counter}\marg{min}\marg{max} adds to \meta{counter}
+% a random integer value between \meta{min} and \meta{max},
+% if \textit{@counterz@random} is TRUE.
+%
+% \begin{macrocode}
+\newcommand{\randaddtocounter}[3]{%
+ \ifrandomizectr{%
+ \addtocounter{#1}{%
+ \the \numexpr #2+\pdfuniformdeviate \numexpr #3-#2+1 \relax
+ }%
+ }{%
+ % Do Nothing
+ }%
+}%
+\newcommand{\xrandaddtocounter}[3]{%
+ \randaddtocounter{\@counterz@counterprefix#1}{#2}{#3}
+}%
+% \end{macrocode}
+%
+%\end{macro}
+%\end{macro}
+% The following commands are designed to provide a means by which authors can
+% generate random values for counters but also preserve those values for future
+% typesettings. This is accomplished by storing counters and their values in an
+% external file and then inputting the file before a subsequent typesetting.
+%
%\begin{macro}{\opencountersfile}
%\changes{v1.1.0}{2023/05/30}{new error reports}
%
@@ -1743,7 +1727,7 @@ and the derived files counterz.ins,
%
% \cs{randprovidecounter}\marg{counter}\marg{min}\marg{max} creates
% \meta{counter} if it does not already exist, and if the boolean
-% \textit{@counterz@random} is true then \meta{counter} is assigned a
+% \textit{@counterz@random} is TRUE then \meta{counter} is assigned a
% random integer value between \meta{min} and \meta{max} and then saved.
%
% \begin{macrocode}
@@ -1772,7 +1756,7 @@ and the derived files counterz.ins,
%
% \cs{xrandprovidecounter}\marg{counter}\marg{min}\marg{max} creates
% \meta{counter} if it does not already exist, and if the boolean
-% \textit{@counterz@random} is true then \meta{counter} is assigned a
+% \textit{@counterz@random} is TRUE then \meta{counter} is assigned a
% random integer value between \meta{min} and \meta{max} and then saved.
%
% \begin{macrocode}