aboutsummaryrefslogtreecommitdiff
path: root/exercisesheets.sty
diff options
context:
space:
mode:
Diffstat (limited to 'exercisesheets.sty')
-rw-r--r--exercisesheets.sty114
1 files changed, 105 insertions, 9 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty
index c066a94..6af4ca1 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.8}
-\def\exsh@date{2021/10/06}
+\def\exsh@version{0.9}
+\def\exsh@date{2021/12/07}
\ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
\message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>}
@@ -56,7 +56,40 @@
\newif\ifexsh@pointsfloatright
\newif\ifexsh@bonus
\newif\ifexsh@abbrev
+\newif\ifexsh@sumuppoints
\newif\ifexsh@filenameasexercisename
+\newif\ifexsh@showtodos
+\newif\ifexsh@beamercompatdone
+
+\def\exsh@beamercompatibility{
+\ifexsh@beamercompatdone
+ \PackageError{exercisesheets}{
+ beamercompatibility used twice}{}%
+\else
+ \let\pause\relax
+ \def\frame{}
+ \renewcommand{\frame}[1][]{}
+ \let\endframe\relax
+ \def\onslide<##1>{}
+ \def\only<##1>{}
+ \def\uncover<##1>{}
+ \def\visible<##1>{}
+ \def\invisible<##1>{}
+ \long\def\alt<##1>##2##3{##2}
+ \long\def\temporal<##1>##2##3##4{##3}
+ \def\uncover<##1>{}
+ \let\exsh@origitem\item
+ \def\exsh@ovrlitem<##1>{\exsh@origitem}
+ \def\item{\@ifnextchar<\exsh@ovrlitem\exsh@origitem}
+ \let\exsh@origitemize\itemize
+ \def\exsh@ovrlitemize[##1]{\exsh@origitemize}
+ \def\itemize{\@ifnextchar[\exsh@ovrlitemize\exsh@origitemize}
+ \let\exsh@origenumerate\enumerate
+ \def\exsh@ovrlenumerate[##1]{\exsh@origenumerate}
+ \def\enumerate{\@ifnextchar[\exsh@ovrlenumerate\exsh@origenumerate}
+ \exsh@beamercompatdonetrue
+\fi
+}
\pgfkeys{/exsh/.is family,/exsh,
solutions/.is choice,
@@ -84,6 +117,8 @@
inplace/.default=true,
sample/.is if=exsh@sample,
sample/.default=true,
+ showtodos/.is if=exsh@showtodos,
+ showtodos/.default=true,
filenameasexercisename/.is if=exsh@filenameasexercisename,
filenameasexercisename/.default=true,
pointsfloatright/.is if=exsh@pointsfloatright,
@@ -100,6 +135,9 @@
framed/.default={ignore},
framed/.initial={ignore},
framed/.code={\let\newframe\relax},
+ beamercompatibility/.default={ignore},
+ beamercompatibility/.initial={ignore},
+ beamercompatibility/.code={\exsh@beamercompatibility},
}
% store title data for sheet headers
@@ -175,6 +213,9 @@
exercisemark/.initial={},
difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden,
custom skip macro/.initial=\exsh@skipcustomstuff,
+ showtodos/.initial={false},
+ hidetodos/.style={/exsh/showtodos=false},
+ hidetodos/.value forbidden,
%
% translatable strings
strings/sheet/.initial={},
@@ -657,11 +698,43 @@
%Do nout use \let here as \label may change before its use
\def\exsh@autolabel{\label}
+\newcounter{exsh@pts@cur}
+\newcounter{exsh@ptsbonus@cur}
\newenvironment*{exercise}[1][]{%
% TODO: \edef is not safe with luatex and umlauts, only fixed for "oral" for now
% TODO: check whether the TODO above is still relevant
%\edef seams to work fine with lualatex from TeXLive 2020
\pgfkeys{exsh,every exercise,#1,includeoverride}%
+ \ifthenelse{\equal{sum}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifcsname exsh@sumpts@\the\numexpr\arabic{section}+1\endcsname
+ \edef\exsh@sumpts{%
+ \csname exsh@sumpts@\the\numexpr\arabic{section}+1%
+ \endcsname%
+ }%
+ \edef\exsh@sumptsbonus{%
+ \csname exsh@sumptsbonus@\the\numexpr\arabic{section}+1%
+ \endcsname%
+ }%
+ \ifnumequal{\exsh@sumpts}{0}{%
+ \ifnumequal{\exsh@sumptsbonus}{0}{}{%
+ \edef\exsh@sumpts{\exsh@sumptsbonus}%
+ \exshset{bonus}%
+ }%
+ }{%
+ \ifnumequal{\exsh@sumptsbonus}{0}{}{%
+ \edef\exsh@sumpts{\exsh@sumpts+\exsh@sumptsbonus}%
+ }%
+ }%
+ \else%
+ \def\exsh@sumpts{??}%
+ \fi%
+ \exshset{points/.expanded={\exsh@sumpts}}
+ \setcounter{exsh@pts@cur}{0}
+ \setcounter{exsh@ptsbonus@cur}{0}
+ \exsh@sumuppointstrue%
+ }{%
+ \exsh@sumuppointsfalse%
+ }%
\ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/points}}}{%
\def\exsh@points{}%
\def\exsh@shortpoints{}%
@@ -745,7 +818,21 @@
% with a new \par. Make sure that a \label does not mess up the layout.
\@ifnextchar\label{\exsh@label}{\leavevmode\ignorespaces}%
}%
-}{}
+}{%
+ %before writing point sums check that we actually computed them
+ \ifexsh@sumuppoints%
+ \immediate\write\@auxout{
+ \string\expandafter\gdef%
+ \detokenize{\csname} exsh@sumpts@\arabic{section}\endcsname{%
+ \arabic{exsh@pts@cur}%
+ }%
+ \string\expandafter\gdef%
+ \detokenize{\csname} exsh@sumptsbonus@\arabic{section}\endcsname{%
+ \arabic{exsh@ptsbonus@cur}%
+ }%
+ }
+ \fi
+}
\newcommand{\exsh@label}[2]{#1{#2}\leavevmode\ignorespaces}
\newcommand{\exsh@startsection}[2][]{%
\@startsection{section}{1}{\z@}%
@@ -925,7 +1012,14 @@
\exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points}\exsh@tmp}%
\fi%
}%
- \fi
+ \fi%
+ \ifexsh@sumuppoints%
+ \ifexsh@bonus%
+ \addtocounter{exsh@ptsbonus@cur}{#2}
+ \else%
+ \addtocounter{exsh@pts@cur}{#2}
+ \fi%
+ \fi%
}%
}%
\egroup
@@ -986,11 +1080,13 @@
\fi%
}
-\newcommand{\TODO}{%
- \ifmmode
- ${\pgfkeysvalueof{/exsh/todo marker font}TODO}$%
- \else
- {\pgfkeysvalueof{/exsh/todo marker font}TODO}%
+\newcommand{\TODO}[1][]{%
+ \ifexsh@showtodos
+ \ifmmode
+ \text{\pgfkeysvalueof{/exsh/todo marker font}TODO #1}%
+ \else
+ {\pgfkeysvalueof{/exsh/todo marker font}TODO #1}%
+ \fi
\fi
\PackageWarning{exercisesheets}{TODO marker found}%
}