diff options
Diffstat (limited to 'exercisesheets.sty')
| -rw-r--r-- | exercisesheets.sty | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty index 6616f9a..9c8c502 100644 --- a/exercisesheets.sty +++ b/exercisesheets.sty @@ -18,8 +18,8 @@ %\NeedsTeXFormat{LaTeX2e}[1994/12/01] % don't forget to update the version and date in exercisesheets.tex -\def\exsh@version{0.10+git} -\def\exsh@date{2022/01/12} +\def\exsh@version{0.11} +\def\exsh@date{2022/02/11} \ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets] \message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>} @@ -43,6 +43,9 @@ \RequirePackage{currfile} \RequirePackage{catchfile} +%we need getrefnumber +\RequirePackage{refcount} + % configuration keys \newif\ifexsh@beamer @@ -877,8 +880,9 @@ {\csname the#1\endcsname\autodot\enskip}}% }{} -%Do nout use \let here as \label may change before its use +%Do not use \let here as \label may change before its use \def\exsh@autolabel{\label} +\def\inexlabel{\label} \newcounter{exsh@pts@cur} \newcounter{exsh@ptsbonus@cur} @@ -1088,6 +1092,7 @@ %auto labelling is still allowed, but other labels are forbidden %here we may use \let as the definition is close to its use \let\exsh@autolabel\label + \let\inexlabel\label \def\label##1{% \PackageError{exercisesheets}{\string\label{##1}\space inside \string\includeexercise*}{}% @@ -1153,9 +1158,23 @@ \labelformat{section}{\pgfkeysvalueof{/exsh/strings/exercise}~\arabic{section}} } + +\let\exsh@subexn\getrefnumber + \ifexsh@patchenumerate \AfterPackage*{varioref}{ \labelformat{enumi}{\arabic{section}.\alph{enumi}} + \def\exsh@afterdot#1.#2{#2}%x.y -> y + \def\exsh@subexn#1{% + \if\getrefnumber{#1}0% + 0% + \else%x.y->y, then inverse \@alph + \the\numexpr(\expandafter\expandafter\expandafter% + \expandafter\expandafter\expandafter% + \expandafter`\expandafter\expandafter\expandafter% + \exsh@afterdot\getrefnumber{#1}-`a+1)\relax% + \fi% + } } \AfterPackage*{paralist}{ \setdefaultenum{(a)}{(1)}{i.}{A.} @@ -1182,6 +1201,29 @@ }% \fi +\newcommand{\subexnref}[1]{\exsh@subexn{#1}} +\newcommand{\subexlref}[1]{(\@alph{\exsh@subexn{#1}})} + +%for now this is not part of the public interface +\exshset{subtask counter/.initial={enumi}} +\exshset{subtask environment/.initial={enumerate}} +\exshset{subtask item/.initial={item}} +\edef\exsh@subtaskctr{\pgfkeysvalueof{/exsh/subtask counter}} +\def\exsh@subtaskenv{\pgfkeysvalueof{/exsh/subtask environment}} +\def\exsh@subtaskitm{\pgfkeysvalueof{/exsh/subtask item}} + +%define subex as an alias for enumi +\expandafter\let\expandafter\c@subex% + \csname c@\exsh@subtaskctr\endcsname +\expandafter\let\expandafter\p@subex% + \csname p@\exsh@subtaskctr\endcsname +\expandafter\let\expandafter\thesubex% + \csname the\exsh@subtaskctr\endcsname +\expandafter\let\expandafter\theHsubex% + \csname theH\exsh@subtaskctr\endcsname +\expandafter\let\expandafter\cl@subex% + \csname cl@\exsh@subtaskctr\endcsname + % reset equation numbering for each exercise \@addtoreset{equation}{section} @@ -1197,25 +1239,6 @@ \ignorespaces }{} -%we ignore everything before the frist item -%and process everything afterwards -\long\def\exsh@processsubtasks#1\item#2\item{% -\ifstrequal{#2}{}{}{% -\item #2% -\csgdef{exsh@restatetask\arabic{enumi}}{#2}% -\exsh@processsubtasks\item%new "frist" \item to ignore -}%no whitespace here is crucial for end detecttion -} - -\long\def\exsh@collectedsubtasks#1{ -\begin{enumerate} -\exsh@processsubtasks#1\item\item -\end{enumerate}% -} - -\def\exsh@subtaskenv{enumerate} -\def\exsh@subtaskitm{item} -\def\exsh@subtaskctr{enumi} \newenvironment{subtasks}[1][]{% \pgfkeys{exsh,#1}% \begin{\exsh@subtaskenv} @@ -1308,7 +1331,7 @@ \pgfkeysvalueof{/exsh/solution title font}% \pgfkeysvalueof{/exsh/strings/solution} % (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}% - \ifnum\@enumdepth>0\alph{enumi}\fi)% + \ifnum\@enumdepth>0\alph{subex}\fi)% \end{alertblock} }{ \begin{beamercolorbox}[rounded=true,wd={#1}]% @@ -1316,7 +1339,7 @@ \pgfkeysvalueof{/exsh/solution title font}% \pgfkeysvalueof{/exsh/strings/solution} % (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}% - \ifnum\@enumdepth>0\alph{enumi}\fi)% + \ifnum\@enumdepth>0\alph{subex}\fi)% \end{beamercolorbox} } } @@ -1367,7 +1390,7 @@ % \pgfkeysvalueof{/exsh/solution title font}% % \pgfkeysvalueof{/exsh/strings/solution} % % (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}% -% \alph{enumi})% +% \alph{subex})% % \endblock \ifbool{exsh@framed}{\exsh@defersolutiontitletrue}{} \ifbool{exsh@defersolutiontitle}{}{% |
