summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex')
-rw-r--r--Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex46
1 files changed, 32 insertions, 14 deletions
diff --git a/Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex b/Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex
index 9bbe5ef985d..e10238aa5a7 100644
--- a/Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex
+++ b/Master/texmf-dist/doc/latex/ran_toks/examples/ran_toks.tex
@@ -1,14 +1,16 @@
\documentclass{article}
\usepackage{ran_toks}
+\usepackage{ifthen}
-%\useThisSeed{606574325}
-\useLastAsSeed
-%\rtdebugtrue
-%\ranToksOn
+\useThisSeed{606574325} % comment out this line, and uncomment next line to get ...
+%\useLastAsSeed % a new pseudo-random sequence each time you compile.
+
+% Other useful switches
+%\ranToksOn % the default
%\ranToksOff
\parindent0pt \parskip6pt
-
+\def\cs#1{\texttt{\char`\\#1}}
\begin{document}
\begin{center}\bfseries
@@ -26,8 +28,8 @@ I have {\nToksFor{myPals}} pals, they are \useRanTok{1}, \useRanTok{2},
\useRanTok{3}, \useRanTok{4}, {\useRanTok{5}} and \useRanTok{6}. (Listed
in the order of best friend to least best friend.)
-Test of the \verb!\bRTVToks!/\verb!\eRTVToks! pair of commands and of the
-\texttt{rtVW} environment.
+Test of the \verb!\bRTVToks!/\verb!\eRTVToks! pair of commands, which encloses
+\texttt{rtVW} environments.
\bRTVToks{myThoughts}%
\begin{rtVW}
@@ -53,11 +55,8 @@ How did that other stuff get in there?
\end{rtVW}
\eRTVToks
\begin{enumerate}
- \item \useRanTok{1}
- \item \useRanTok{2}
- \item \useRanTok{3}
+ \displayListRandomly[\item]{myThoughts}
\end{enumerate}
-
Use \verb!\useRTName! command when another list separates the current
position from the list you want to use. Here we want to use the list named
\texttt{myPals}, but since that definition, a new list named
@@ -70,8 +69,27 @@ List of pals: \useRanTok{1}, \useRanTok{2}, \useRanTok{3},
For mixing lists. it might be easier to use the optional parameter:
{\useRanTok[myPals]{1}} and \useRanTok[myThoughts]{1}
-The \verb!\rtTokByNum! can retrieve an item from the list, in its declared
-order; eg, from the \texttt{myPals} list, the first and last are {\rtTokByNum[myPals]{1}}
-and \rtTokByNum[myPals]{\nToksFor{myPals}}.
+The \cs{rtTokByNum} can retrieve an item from the list in its declared order;
+eg, from the \texttt{myPals} list, the first and last are
+{\rtTokByNum[myPals]{1}} and \rtTokByNum[myPals]{\nToksFor{myPals}}.
+
+We demonstrate the command \cs{reorderRanToks} and the optional parameters of \cs{displayListRandomly}:
+\begin{quote}\reorderRanToks{myPals}%
+List of pals: \displayListRandomly[\ifnum\i=\last\space and \fi][\ifnum\i=\last.\else,\fi\space]{myPals}
+\end{quote}
+The reordering is global, so \displayListRandomly[\ifnum\i=\last\space and \fi][\ifnum\i=\last\else, \fi]{myPals}
+are listed in the same order as above, and different from the original random order seen in the second paragraph
+of this document.
+
+Without the Oxford comma: My pals are
+\displayListRandomly[\ifnum\i=\last and \fi][\ifnum\i=\last.\else\ifnum\i=\lessone\relax\space\else, \fi\fi]{myPals}
+
+The following is the same logic but uses the syntax of the \textsf{ifthen} package: My pals are
+\displayListRandomly[\ifthenelse{\i=\last}{and }{}][\ifthenelse{\i=\last}{.}{\ifthenelse{\i=\lessone}{\space}{, }}]{myPals}
+
+Test the \cs{copyRanToks} command:
+\copyRanToks{myPals}{myPals1}\displayListRandomly[\ifthenelse{\i=\last}{and }{}][\ifthenelse{\i=\last}{.}{\ifthenelse{\i=\lessone}{\space}{, }}]{myPals1}
+This does not change the order of the \texttt{myPals} list, which is still
+\displayListRandomly[\ifnum\i=\last\space and \fi][\ifnum\i=\last.\else,\fi\space]{myPals}
\end{document}