diff options
| author | Frank Fuhlbrück | 2022-01-07 17:23:31 +0100 |
|---|---|---|
| committer | Frank Fuhlbrück | 2022-01-07 17:23:31 +0100 |
| commit | 61c4c1776a667a4952e8f9817d545c55e50b8009 (patch) | |
| tree | 49a1b2d7554c8f51e0cbd668694a1fdb16826f7b | |
| parent | 878945fe271424eec2cf3100676b770dc654e266 (diff) | |
| download | exercisesheets-61c4c1776a667a4952e8f9817d545c55e50b8009.tar.gz exercisesheets-61c4c1776a667a4952e8f9817d545c55e50b8009.tar.bz2 exercisesheets-61c4c1776a667a4952e8f9817d545c55e50b8009.zip | |
exsh v0.9: beamercomp.,better todo,points=sum
| -rw-r--r-- | README | 2 | ||||
| -rw-r--r-- | exercisesheets-beamer.sty | 102 | ||||
| -rw-r--r-- | exercisesheets.sty | 114 | ||||
| -rw-r--r-- | exercisesheets.tex | 79 |
4 files changed, 265 insertions, 32 deletions
@@ -4,7 +4,7 @@ The exercisesheets package provides a way to typeset exercise sheets as used in university courses. It evolved from a set of macros an environments that were finally combined into this package. -Copyright (c) 2008-2019 Sebastian Kuhnert, Frank Fuhlbrück +Copyright (c) 2008-2022 Sebastian Kuhnert, Frank Fuhlbrück Licence: LPPL 1.3c or later Current Maintainer: Sebastian Kuhnert 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}% } 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}% } diff --git a/exercisesheets.tex b/exercisesheets.tex index 887e5b4..b1d0fff 100644 --- a/exercisesheets.tex +++ b/exercisesheets.tex @@ -53,7 +53,7 @@ \usepackage[english,iso]{isodate} \title{The \exsh Package} \author{Sebastian Kuhnert\and Frank Fuhlbrück} -\date{Version 0.8, \printdateTeX{2021/10/06}} +\date{Version 0.9, \printdateTeX{2022/01/07}} \begin{document} \maketitle @@ -66,7 +66,7 @@ This variant is called exercisesheets-beamer. Not all combinations of options ha \subsection*{Licence} -Copyright \textcopyright{} 2008--2021 Sebastian Kuhnert and Frank Fuhlbrück. +Copyright \textcopyright{} 2008--2022 Sebastian Kuhnert and Frank Fuhlbrück. Permission is granted to copy, distribute and/or modify this software under the terms of the \LaTeX{} Project Public Licence, version 1.3c or later. This package is maintained, the Current Maintainer is Sebastian @@ -179,6 +179,46 @@ The following options are available: \item[\option{exercisespath}] Set the (relative) path of the directory containing exercises to be included via \verb|\includeexercise|. + \item[\option{showtodos} / \option{hidetodos}] + \verb|\TODO| markers + are hidden by default, this option switches their behavior. This + option is usually set within \verb|\ifsamplesolutions| or + similar. + \item[\option{beamercompatibility}] + This options (which only is effective in the non-beamer version) + defines several beamer macros with as trivial + effects as possible, e.g., \verb|\pause| becomes \verb|\relax| + and overlay specifications are mostly ignored. Be careful to use + this option after loading \verb|enumitem| etc. as the enumerate + and itemize environment are defined to swallow overlay + specifications without effect, this also holds for + \verb|\item<1->|. The current list of redefinitions is as + follows: +\begin{lstlisting} + \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} +\end{lstlisting} \end{description} @@ -278,8 +318,16 @@ supported: Useful for exercises that prove a famous theorem. \item[\option{firstline=\param{text}}] Save some space by text \param{text} behind the exercise title. - \item[\option{points=\param{number}}] Assign this exercise \param{number} - points. By default, exercises are unlabelled. + \item[\option{points=\param{number/oral/sum}}] Assign this + exercise \param{number} points. By default, exercises are + unlabelled. \param{oral} works the same way as the option + \option{oral}. The value \param{sum} displays the sum of all + occurrences of \verb|\points| within the exercise: Ordinary and + bonus points are treated separately. If there are only bonus + points, the option \option{bonus} is automatically triggered. To + undo this, either delete the \verb|.aux| file or explicitly use + \verb|\points[bonus=false]{\param{number}}| for at least one + subexercise. \item[\option{oral}] Label this exercise as \emph{oral}. This supersedes and is superseded by the option \option{points}. \item[\option{pointsinfo=\param{text}}] Supply \param{text} as additional @@ -299,12 +347,13 @@ supported: \item[\option{beamersolution}] For \exsh-beamer only. If this option is set all normal solutions will not be included and only \option{beamersolution}s are typeset. - \item[\option{framed}] For \exsh-beamer only. If this option - is set for a normal solution, its content will be put on one or more - frames. Use \verb|\newframe| to start a new frame. This option is - especially helpful if you provide your own definitions of - \verb|\only| etc. for non-beamer compilation. \verb|\newframe| is - already defined as \verb|\relax| in non-beamer \exsh. + \item[\option{framed}] For \exsh-beamer only, simply ignored + elsewhere. If this option + is set for a normal solution, its content will be put on one or + more frames. Use \verb|\newframe| to start a new frame. This + option is especially helpful if you provide your own definitions + of \verb|\only| etc. for non-beamer compilation. \verb|\newframe| + is already defined as \verb|\relax| in non-beamer \exsh. \end{description} Solutions are only typeset, if the \option{solutions} option is in effect. There @@ -351,10 +400,12 @@ starts a new paragraph, the second one puts the hint in parenthesis. You can use the following to include a red TODO marker in your document. This is useful to mark places where work is still in progress. A warning is issued at -each place. +each place. TODO markers can also contain an optional description +of the task that needs to be done. If you switch off displaying +TODO markers (s.a.) the warning will be issued nevertheless. \begin{lstlisting} -\TODO +\TODO[what needs to be done] \end{lstlisting} \subsection{Annotating Points for Sub-Exercises} @@ -538,6 +589,10 @@ the environments defined by this package: false}\}}] Execute \param{options if true} if solutions for non-oral exercises are included in the current document, \param{options if false} otherwise. + \item[\option{ifsamplesolutions=\{\param{options if true}\}\{\param{options if + false}\}}] Execute \param{options if true} if sample solutions for marked + exercises are included in the current document, \param{options if false} + otherwise. \end{description} Example 1: Only include points for sub-exercises when solutions are typeset: |
