diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/scrambledenvs/README.md | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/scrambledenvs/scrambledenvs.pdf | bin | 191784 -> 198912 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/scrambledenvs/scrambledenvs.dtx | 116 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/scrambledenvs/scrambledenvs.sty | 52 |
4 files changed, 133 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/latex/scrambledenvs/README.md b/Master/texmf-dist/doc/latex/scrambledenvs/README.md index ed9e9eebef6..5693fbf0501 100644 --- a/Master/texmf-dist/doc/latex/scrambledenvs/README.md +++ b/Master/texmf-dist/doc/latex/scrambledenvs/README.md @@ -1,4 +1,4 @@ -# The LaTeX package scrambledenvs - version 1.0.1 (2021/08/03) +# The LaTeX package scrambledenvs - version 1.1.0 (2021/09/26) > Copyright (C) 2021 Dennis Chen proofprogram@gmail.com > diff --git a/Master/texmf-dist/doc/latex/scrambledenvs/scrambledenvs.pdf b/Master/texmf-dist/doc/latex/scrambledenvs/scrambledenvs.pdf Binary files differindex a2df1c1553f..b2476364dbc 100644 --- a/Master/texmf-dist/doc/latex/scrambledenvs/scrambledenvs.pdf +++ b/Master/texmf-dist/doc/latex/scrambledenvs/scrambledenvs.pdf diff --git a/Master/texmf-dist/source/latex/scrambledenvs/scrambledenvs.dtx b/Master/texmf-dist/source/latex/scrambledenvs/scrambledenvs.dtx index bc51131fd89..111bcab0571 100644 --- a/Master/texmf-dist/source/latex/scrambledenvs/scrambledenvs.dtx +++ b/Master/texmf-dist/source/latex/scrambledenvs/scrambledenvs.dtx @@ -15,7 +15,7 @@ \iffalse %</internal> %<*readme> -# The LaTeX package scrambledenvs - version 1.0.1 (2021/08/03) +# The LaTeX package scrambledenvs - version 1.1.0 (2021/09/26) > Copyright (C) 2021 Dennis Chen proofprogram@gmail.com > @@ -119,13 +119,14 @@ This package consists of the file scrambledenvs.dtx, %</internal> %<*main> \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{scrambledenvs}[2021/08/03 v1.0.1 Create and print scrambled environments] +\ProvidesPackage{scrambledenvs}[2021/09/26 v1.1.0 Create and print scrambled environments] +\RequirePackage{ifthen} \RequirePackage{forloop} \RequirePackage{pgfmath} \pgfmathsetseed{2407} %</main> %<*driver> -\ProvidesFile{\jobname.dtx}[2021/08/03 v1.0.1 Create and print scrambled environments] +\ProvidesFile{\jobname.dtx}[2021/09/26 v1.1.0 Create and print scrambled environments] \documentclass{ltxdoc} \EnableCrossrefs @@ -217,6 +218,7 @@ This package consists of the file scrambledenvs.dtx, %</helper> % \fi % \DescribeEnv{hints} +% \changes{v1.1.0}{2021/09/26}{Fix internal bug when referencing counters} % \changes{v1.0.1}{2021/08/03}{Adjust spacing to make two scrambled envs look prettier together} % This is the outer environment. Depending on how many |hint| environments are put inside it, it will either typeset \emph{Hints:} or \emph{Hint:} with the numerical labels of the passed in hints following it. % You should put in nothing but the inner environment |hint|. (See the examples for a correct usage.) @@ -234,11 +236,11 @@ This package consists of the file scrambledenvs.dtx, \else \ifnum\value{scrambledenvs@#1@tempcount}=1\relax {\csname scrambledenvs@#1@labelfont\endcsname\csname scrambledenvs@#1@label\endcsname :} - {\csname scrambledenvs@#1@reffont\endcsname\ref{#1:\value{scrambledenvs@#1@count}}}% + {\csname scrambledenvs@#1@reffont\endcsname\csname scrambledenvs@#1@refprefix\endcsname\ref{#1:\the\numexpr\value{scrambledenvs@#1@count}}}% \else {\csname scrambledenvs@#1@labelfont\endcsname\csname scrambledenvs@#1@label\endcsname s:} \forloop{scrambledenvs@loopcount}{\the\numexpr\value{scrambledenvs@#1@count}-\value{scrambledenvs@#1@tempcount}+1\relax}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax} {% - {\csname scrambledenvs@#1@reffont\endcsname\ref{#1:\thescrambledenvs@loopcount}} + {\csname scrambledenvs@#1@reffont\endcsname\csname scrambledenvs@#1@refprefix\endcsname\ref{#1:\thescrambledenvs@loopcount}} } \fi \fi @@ -268,40 +270,62 @@ This package consists of the file scrambledenvs.dtx, % \fi % % \DescribeMacro{\printhint} -% +% \changes{v1.1.0}{2021/09/26}{Feature: printhint only outputs unprinted hints (allows for printhint in each chapter, etc)} +% \changes{v1.1.0}{2021/09/26}{Bugfix: switch from forloop to TeX loops} % To print out the hints (either in a random or fixed order, depending on whether the option |noscramble| is passed in), just write |\printhint|. % +% Only hints that have not been printed before will be printed. Therefore, in a book, you could write |\printhint| at the end of each chapter to get end-of-chapter hints. +% +% By default, the hint counter resets each time. So if you use |\printhint| twice, you will have two hint 1's, etc. If you want the counter to continue, the following code will work: +%\begin{verbatim} +%\hintprintenv{\begin{enumerate}\setcounter{enumi}{\the\numexpr\csname scrambledenvs@hint@start\endcsname-1\relax}}{\end{enumerate}} +%\end{verbatim} +% Wrap this with a |\makeatletter| |\makeatother| pair if appropriate (i.e. in TeX files). % \iffalse %<*helper> \newcounter{scrambledenvs@loopcount} \newcounter{scrambledenvs@innerloopcount} %</helper> %<*main> +\expandafter\def\csname scrambledenvs@#1@start\endcsname{1} \expandafter\newcommand\csname print#1\endcsname{% \ifscrambledenvs@scramble %\if \ifcsname thescrambledenvs@#1@count\endcsname - \ifnum\value{scrambledenvs@#1@count}>0\relax - \expandafter\edef\csname pgfmath@randomlist@#1\endcsname{\value{scrambledenvs@#1@count}}% - \forloop{scrambledenvs@loopcount}{1}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{\expandafter\edef\csname pgfmath@randomlist@#1@\thescrambledenvs@loopcount\endcsname{\thescrambledenvs@loopcount}}% - \begin{scrambledenvs@#1@printenv}% - \forloop{scrambledenvs@loopcount}{0}{\value{scrambledenvs@loopcount}<\value{scrambledenvs@#1@count}}{% - \pgfmathrandomitem\scrambledenvs@tempindex{#1}% - \csname scrambledenvs@#1@printitem\endcsname\label{#1:\scrambledenvs@tempindex}% + \ifnum\value{scrambledenvs@#1@count}<\csname scrambledenvs@#1@start\endcsname\relax + \else + \expandafter\edef\csname pgfmath@randomlist@#1\endcsname{\numexpr\value{scrambledenvs@#1@count}-\csname scrambledenvs@#1@start\endcsname+1} + \count@=1 + \loop + \expandafter\edef\csname pgfmath@randomlist@#1@\the\count@\endcsname{\the\numexpr\count@+\csname scrambledenvs@#1@start\endcsname-1\relax} + \ifnum\count@<\numexpr\value{scrambledenvs@#1@count}-\csname scrambledenvs@#1@start\endcsname+1\relax + \advance\count@ 1 + \repeat + \begin{scrambledenvs@#1@printenv} + \setcounter{scrambledenvs@loopcount}{\csname scrambledenvs@#1@start\endcsname} + \whiledo{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{% + \stepcounter{scrambledenvs@loopcount} + \pgfmathrandomitem\scrambledenvs@tempindex{#1} + \csname scrambledenvs@#1@printitem\endcsname\label{#1:\scrambledenvs@tempindex}% \input{\jobname-\scrambledenvs@tempindex.#1}% - \forloop{scrambledenvs@innerloopcount}{\scrambledenvs@tempindex}{\value{scrambledenvs@innerloopcount}<\csname pgfmath@randomlist@#1\endcsname}{% - \global\expandafter\let\csname pgfmath@randomlist@#1@\thescrambledenvs@innerloopcount\expandafter\endcsname\csname pgfmath@randomlist@#1@\the\numexpr\thescrambledenvs@innerloopcount+1\relax\endcsname% - }% - \expandafter\xdef\csname pgfmath@randomlist@#1\endcsname{\the\numexpr\csname pgfmath@randomlist@#1\endcsname-1\relax}% - }% + \count@\pgfmath@randomtemp + \loop + \global\expandafter\let\csname pgfmath@randomlist@#1@\the\count@\expandafter\endcsname\csname pgfmath@randomlist@#1@\the\numexpr\the\count@+1\relax\endcsname% + \advance\count@ 1 + \ifnum \count@ < \csname pgfmath@randomlist@#1\endcsname\relax + \repeat + \expandafter\xdef\csname pgfmath@randomlist@#1\endcsname{\the\numexpr\csname pgfmath@randomlist@#1\endcsname-1\relax}% + } \end{scrambledenvs@#1@printenv} + \expandafter\edef\csname scrambledenvs@#1@start\endcsname{\the\numexpr\value{scrambledenvs@#1@count}+1\relax} \fi \fi \else \ifcsname thescrambledenvs@#1@count\endcsname \ifnum\value{scrambledenvs@#1@count}>0\relax \begin{scrambledenvs@#1@printenv}% - \forloop{scrambledenvs@loopcount}{1}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{\csname scrambledenvs@#1@printitem\endcsname\label{#1:\thescrambledenvs@loopcount}\input{\jobname-\thescrambledenvs@loopcount.#1}}% + \forloop{scrambledenvs@loopcount}{\csname scrambledenvs@#1@start\endcsname}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{\csname scrambledenvs@#1@printitem\endcsname\label{#1:\thescrambledenvs@loopcount}\input{\jobname-\thescrambledenvs@loopcount.#1}}% \end{scrambledenvs@#1@printenv} + \expandafter\edef\csname scrambledenvs@#1@start\endcsname{\the\numexpr\value{scrambledenvs@#1@count}+1\relax} \fi \fi \fi @@ -338,12 +362,24 @@ This package consists of the file scrambledenvs.dtx, \expandafter\newcommand\csname #1labelfont\endcsname[1]{\expandafter\def\csname scrambledenvs@#1@labelfont\endcsname{##1}} %</main> % \fi +% \changes{v1.1.0}{2021/09/26}{Added ref prefix} +% \DescribeMacro{\hintrefprefix} +% Sets the prefix before the reference. (This may be useful if you have multiple |\printhint| statements, like one at the end of each chapter.) % +% \iffalse +%<*main> +\expandafter\def\csname scrambledenvs@#1@refprefix\endcsname{\scrambledenvs@refprefix} +\scrambledenvs@check@macrodefined{#1refprefix} +\expandafter\newcommand\csname #1refprefix\endcsname[1]{\expandafter\def\csname scrambledenvs@#1@refprefix\endcsname{##1}} +%</main> +% \fi % \DescribeMacro{\hintreffont} % Sets the font of the numerical references the follows the label. % % If you are using hyperref and you are using the |colorlinks| option: because the references are generated with |\ref|, you must change hyperref colors in order to change the color. |\color| will not work. Otherwise |\color| will work. % +% If you are using hyperref \emph{and} have a prefix, since the prefix is not part of the label, you must use \emph{both} |\hypersetup| and |\color|. +% % \iffalse %<*main> \expandafter\def\csname scrambledenvs@#1@reffont\endcsname{\scrambledenvs@reffont} @@ -392,6 +428,15 @@ This package consists of the file scrambledenvs.dtx, %</helper> % \fi % +% \DescribeMacro{\defaultrefprefix} +% Changes the default reference prefix. +% \iffalse +%<*helper> +\def\scrambledenvs@refprefix{} +\def\defaultrefprefix#1{\def\scrambledenvs@refprefix{#1}} +%</helper> +% \fi +% % \DescribeMacro{\defaultreffont} % Changes the default reference font. % \iffalse @@ -456,7 +501,7 @@ This package consists of the file scrambledenvs.dtx, %\hintprintenv{\begin{enumerate}\small}{\end{enumerate}} %\hintprintitem{\bfseries\item} %\end{verbatim} -% \subsection{Changing hintreffont color: hpyerrefs colorlink} +% \subsection{Changing hintreffont color: hyperrefs colorlink} % Since we are using |\ref| to typeset labels (which are set with |\label|), if we use |colorlinks| from package |hyperref| we must locally change the linkcolor in order to change the color the numbers are typeset in. %\begin{verbatim} %\documentclass{article} @@ -467,6 +512,37 @@ This package consists of the file scrambledenvs.dtx, %\newscrambledenv{hint} %\hintreffont{\hypersetup{linkcolor=blue}} %\end{verbatim} +%\subsection{Changing hint ref prefix} +%\begin{verbatim} +%\documentclass{article} +%\usepackage{scrambledenvs} +%\usepackage{xcolor} +%\usepackage{hyperref} +%\hypersetup{colorlinks} +%\newscrambledenv{hint} +%\hintrefprefix{\thesection.} +%\hintreffont{\color{blue}\hypersetup{linkcolor=blue}} +%\begin{document} +%\section{First Problem} +%This is a problem. +%\begin{hints} +%\begin{hint} +%This hint will be referenced as 1.1. +%\end{hint} +%\end{hints} +%\subsection{Hints} +%\printhint +%\section{Second Problem} +%This is another problem. +%\begin{hints} +%\begin{hint} +%This hint will be referenced as 2.1. +%\end{hint} +%\end{hints} +%\subsection{Hints} +%\printhint +%\end{document} +%\end{verbatim} % ^^A At the end, close brace %\iffalse %<*main> diff --git a/Master/texmf-dist/tex/latex/scrambledenvs/scrambledenvs.sty b/Master/texmf-dist/tex/latex/scrambledenvs/scrambledenvs.sty index 3b44bedbeac..615acf1051e 100644 --- a/Master/texmf-dist/tex/latex/scrambledenvs/scrambledenvs.sty +++ b/Master/texmf-dist/tex/latex/scrambledenvs/scrambledenvs.sty @@ -27,7 +27,8 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{scrambledenvs}[2021/08/03 v1.0.1 Create and print scrambled environments] +\ProvidesPackage{scrambledenvs}[2021/09/26 v1.1.0 Create and print scrambled environments] +\RequirePackage{ifthen} \RequirePackage{forloop} \RequirePackage{pgfmath} \pgfmathsetseed{2407} @@ -49,11 +50,11 @@ \else \ifnum\value{scrambledenvs@#1@tempcount}=1\relax {\csname scrambledenvs@#1@labelfont\endcsname\csname scrambledenvs@#1@label\endcsname :} - {\csname scrambledenvs@#1@reffont\endcsname\ref{#1:\value{scrambledenvs@#1@count}}}% + {\csname scrambledenvs@#1@reffont\endcsname\csname scrambledenvs@#1@refprefix\endcsname\ref{#1:\the\numexpr\value{scrambledenvs@#1@count}}}% \else {\csname scrambledenvs@#1@labelfont\endcsname\csname scrambledenvs@#1@label\endcsname s:} \forloop{scrambledenvs@loopcount}{\the\numexpr\value{scrambledenvs@#1@count}-\value{scrambledenvs@#1@tempcount}+1\relax}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax} {% - {\csname scrambledenvs@#1@reffont\endcsname\ref{#1:\thescrambledenvs@loopcount}} + {\csname scrambledenvs@#1@reffont\endcsname\csname scrambledenvs@#1@refprefix\endcsname\ref{#1:\thescrambledenvs@loopcount}} } \fi \fi @@ -72,31 +73,45 @@ {% \endfilecontents } +\expandafter\def\csname scrambledenvs@#1@start\endcsname{1} \expandafter\newcommand\csname print#1\endcsname{% \ifscrambledenvs@scramble %\if \ifcsname thescrambledenvs@#1@count\endcsname - \ifnum\value{scrambledenvs@#1@count}>0\relax - \expandafter\edef\csname pgfmath@randomlist@#1\endcsname{\value{scrambledenvs@#1@count}}% - \forloop{scrambledenvs@loopcount}{1}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{\expandafter\edef\csname pgfmath@randomlist@#1@\thescrambledenvs@loopcount\endcsname{\thescrambledenvs@loopcount}}% - \begin{scrambledenvs@#1@printenv}% - \forloop{scrambledenvs@loopcount}{0}{\value{scrambledenvs@loopcount}<\value{scrambledenvs@#1@count}}{% - \pgfmathrandomitem\scrambledenvs@tempindex{#1}% - \csname scrambledenvs@#1@printitem\endcsname\label{#1:\scrambledenvs@tempindex}% + \ifnum\value{scrambledenvs@#1@count}<\csname scrambledenvs@#1@start\endcsname\relax + \else + \expandafter\edef\csname pgfmath@randomlist@#1\endcsname{\numexpr\value{scrambledenvs@#1@count}-\csname scrambledenvs@#1@start\endcsname+1} + \count@=1 + \loop + \expandafter\edef\csname pgfmath@randomlist@#1@\the\count@\endcsname{\the\numexpr\count@+\csname scrambledenvs@#1@start\endcsname-1\relax} + \ifnum\count@<\numexpr\value{scrambledenvs@#1@count}-\csname scrambledenvs@#1@start\endcsname+1\relax + \advance\count@ 1 + \repeat + \begin{scrambledenvs@#1@printenv} + \setcounter{scrambledenvs@loopcount}{\csname scrambledenvs@#1@start\endcsname} + \whiledo{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{% + \stepcounter{scrambledenvs@loopcount} + \pgfmathrandomitem\scrambledenvs@tempindex{#1} + \csname scrambledenvs@#1@printitem\endcsname\label{#1:\scrambledenvs@tempindex}% \input{\jobname-\scrambledenvs@tempindex.#1}% - \forloop{scrambledenvs@innerloopcount}{\scrambledenvs@tempindex}{\value{scrambledenvs@innerloopcount}<\csname pgfmath@randomlist@#1\endcsname}{% - \global\expandafter\let\csname pgfmath@randomlist@#1@\thescrambledenvs@innerloopcount\expandafter\endcsname\csname pgfmath@randomlist@#1@\the\numexpr\thescrambledenvs@innerloopcount+1\relax\endcsname% - }% - \expandafter\xdef\csname pgfmath@randomlist@#1\endcsname{\the\numexpr\csname pgfmath@randomlist@#1\endcsname-1\relax}% - }% + \count@\pgfmath@randomtemp + \loop + \global\expandafter\let\csname pgfmath@randomlist@#1@\the\count@\expandafter\endcsname\csname pgfmath@randomlist@#1@\the\numexpr\the\count@+1\relax\endcsname% + \advance\count@ 1 + \ifnum \count@ < \csname pgfmath@randomlist@#1\endcsname\relax + \repeat + \expandafter\xdef\csname pgfmath@randomlist@#1\endcsname{\the\numexpr\csname pgfmath@randomlist@#1\endcsname-1\relax}% + } \end{scrambledenvs@#1@printenv} + \expandafter\edef\csname scrambledenvs@#1@start\endcsname{\the\numexpr\value{scrambledenvs@#1@count}+1\relax} \fi \fi \else \ifcsname thescrambledenvs@#1@count\endcsname \ifnum\value{scrambledenvs@#1@count}>0\relax \begin{scrambledenvs@#1@printenv}% - \forloop{scrambledenvs@loopcount}{1}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{\csname scrambledenvs@#1@printitem\endcsname\label{#1:\thescrambledenvs@loopcount}\input{\jobname-\thescrambledenvs@loopcount.#1}}% + \forloop{scrambledenvs@loopcount}{\csname scrambledenvs@#1@start\endcsname}{\value{scrambledenvs@loopcount}<\the\numexpr\value{scrambledenvs@#1@count}+1\relax}{\csname scrambledenvs@#1@printitem\endcsname\label{#1:\thescrambledenvs@loopcount}\input{\jobname-\thescrambledenvs@loopcount.#1}}% \end{scrambledenvs@#1@printenv} + \expandafter\edef\csname scrambledenvs@#1@start\endcsname{\the\numexpr\value{scrambledenvs@#1@count}+1\relax} \fi \fi \fi @@ -107,6 +122,9 @@ \expandafter\def\csname scrambledenvs@#1@labelfont\endcsname{\scrambledenvs@labelfont} \scrambledenvs@check@macrodefined{#1labelfont} \expandafter\newcommand\csname #1labelfont\endcsname[1]{\expandafter\def\csname scrambledenvs@#1@labelfont\endcsname{##1}} +\expandafter\def\csname scrambledenvs@#1@refprefix\endcsname{\scrambledenvs@refprefix} +\scrambledenvs@check@macrodefined{#1refprefix} +\expandafter\newcommand\csname #1refprefix\endcsname[1]{\expandafter\def\csname scrambledenvs@#1@refprefix\endcsname{##1}} \expandafter\def\csname scrambledenvs@#1@reffont\endcsname{\scrambledenvs@reffont} \scrambledenvs@check@macrodefined{#1reffont} \expandafter\newcommand\csname #1reffont\endcsname[1]{\expandafter\def\csname scrambledenvs@#1@reffont\endcsname{##1}} @@ -138,6 +156,8 @@ \newcounter{scrambledenvs@innerloopcount} \def\scrambledenvs@labelfont{\bfseries} \def\defaultlabelfont#1{\def\scrambledenvs@lineformat{#1}} +\def\scrambledenvs@refprefix{} +\def\defaultrefprefix#1{\def\scrambledenvs@refprefix{#1}} \def\scrambledenvs@reffont{} \def\defaultreffont#1{\def\scrambledenvs@reffont{#1}} \newenvironment{scrambledenvs@printenv}{\begin{enumerate}}{\end{enumerate}} |