aboutsummaryrefslogtreecommitdiff
path: root/exercisesheets-beamer.sty
diff options
context:
space:
mode:
authorFrank Fuhlbrück2022-01-07 17:23:31 +0100
committerFrank Fuhlbrück2022-01-07 17:23:31 +0100
commit61c4c1776a667a4952e8f9817d545c55e50b8009 (patch)
tree49a1b2d7554c8f51e0cbd668694a1fdb16826f7b /exercisesheets-beamer.sty
parent878945fe271424eec2cf3100676b770dc654e266 (diff)
downloadexercisesheets-61c4c1776a667a4952e8f9817d545c55e50b8009.tar.gz
exercisesheets-61c4c1776a667a4952e8f9817d545c55e50b8009.tar.bz2
exercisesheets-61c4c1776a667a4952e8f9817d545c55e50b8009.zip
exsh v0.9: beamercomp.,better todo,points=sum
Diffstat (limited to 'exercisesheets-beamer.sty')
-rw-r--r--exercisesheets-beamer.sty102
1 files changed, 92 insertions, 10 deletions
diff --git a/exercisesheets-beamer.sty b/exercisesheets-beamer.sty
index 2508e89..d1dafab 100644
--- a/exercisesheets-beamer.sty
+++ b/exercisesheets-beamer.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-Beamer}
-\def\exsh@date{2021/10/06}
+\def\exsh@version{0.9-Beamer}
+\def\exsh@date{2021/12/07}
\ProvidesPackage{exercisesheets-beamer}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
\message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>}
@@ -61,7 +61,19 @@
\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
+ \exsh@beamercompatdonetrue
+\fi
+}
\pgfkeys{/exsh/.is family,/exsh,
solutions/.is choice,
@@ -85,6 +97,9 @@
defersolutiontitle/.default=true,
framed/.is if=exsh@framed,
framed/.default=true,
+ beamercompatibility/.default={ignore},
+ beamercompatibility/.initial={ignore},
+ beamercompatibility/.code={\exsh@beamercompatibility},
gradingguides/.is if=exsh@gradingguides,
gradingguides/.default=true,
only/.initial={-},
@@ -99,6 +114,8 @@
inplace/.default=true,
sample/.is if=exsh@sample,
sample/.default=true,
+ showtodos/.is if=exsh@showtodos,
+ showtodos/.default=true,
pointsfloatright/.is if=exsh@pointsfloatright,
pointsfloatright/.default=true,
abbrev/.is if=exsh@abbrev,
@@ -183,6 +200,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={},
@@ -662,9 +682,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{}%
@@ -748,7 +802,20 @@
% 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
\clearpage%
}
\newcommand{\exsh@label}[2]{#1{#2}\leavevmode\ignorespaces}
@@ -895,7 +962,14 @@
}%no whitespace here is crucial for end detecttion
}
+
\long\def\exsh@collectedframe#1{
+\newwrite\file
+\immediate\openout\file=tmp\thesection.txt
+\immediate\write\file{
+\detokenize{#1}
+}
+\closeout\file
\exsh@processframes#1\newframe\newframe
}
@@ -1009,7 +1083,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
@@ -1070,15 +1151,16 @@
\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}%
}
-
\newcommand{\ifsolutions}[2]{%
\ifbool{exsh@solutions}{#1}{#2}%
}