aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--README16
-rw-r--r--examples/exercises/exshexample-ex1.tex4
-rw-r--r--examples/exercises/exshexample-ex2.lua4
l---------examples/exercisesheets.sty1
l---------examples/exsh_lexercise.lua1
-rw-r--r--examples/exshexample.tex262
-rw-r--r--exercisesheets.el113
-rw-r--r--exercisesheets.sty1733
-rw-r--r--exercisesheets.tex835
-rw-r--r--exsh_lexercise.lua136
11 files changed, 3109 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2aa950b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/*.aux
+/*.log
+/*.out
+/exercisesheets.pdf
diff --git a/README b/README
new file mode 100644
index 0000000..dd02b18
--- /dev/null
+++ b/README
@@ -0,0 +1,16 @@
+The exercisesheets package
+
+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-2022 Sebastian Kuhnert, Frank Fuhlbrück
+Licence: LPPL 1.3c or later
+Current Maintainer: Frank Fuhlbrück
+
+Files belonging to this package:
+exercisesheets.sty The package itself
+exercisesheets.tex Documentation source
+exercisesheets.el Emacs integration (outdated)
+README This file
+Examples Folder with example file
diff --git a/examples/exercises/exshexample-ex1.tex b/examples/exercises/exshexample-ex1.tex
new file mode 100644
index 0000000..2e91246
--- /dev/null
+++ b/examples/exercises/exshexample-ex1.tex
@@ -0,0 +1,4 @@
+\begin{exercise}
+ Include an exercise from an external file.
+\end{exercise}
+
diff --git a/examples/exercises/exshexample-ex2.lua b/examples/exercises/exshexample-ex2.lua
new file mode 100644
index 0000000..1506e26
--- /dev/null
+++ b/examples/exercises/exshexample-ex2.lua
@@ -0,0 +1,4 @@
+return exercise {
+ task = [[Include an exercise via the Lua interface.]]
+}
+
diff --git a/examples/exercisesheets.sty b/examples/exercisesheets.sty
new file mode 120000
index 0000000..ce51e96
--- /dev/null
+++ b/examples/exercisesheets.sty
@@ -0,0 +1 @@
+../exercisesheets.sty \ No newline at end of file
diff --git a/examples/exsh_lexercise.lua b/examples/exsh_lexercise.lua
new file mode 120000
index 0000000..0669efc
--- /dev/null
+++ b/examples/exsh_lexercise.lua
@@ -0,0 +1 @@
+../exsh_lexercise.lua \ No newline at end of file
diff --git a/examples/exshexample.tex b/examples/exshexample.tex
new file mode 100644
index 0000000..bc4d3ec
--- /dev/null
+++ b/examples/exshexample.tex
@@ -0,0 +1,262 @@
+\long\def\ifbeamer#1#2{#1}
+\ifbeamer{\documentclass{beamer}}{\documentclass{article}}
+
+%navigation symbols and the title collide if
+%beamerwithheadline is set
+\ifbeamer{
+ \setbeamertemplate{navigation symbols}{}
+}{}
+
+%patchenumerate is the deafault
+\usepackage[patchenumerate=true,beamerwithheadline,
+ beamercompatibility,
+ exercisespath=exercises]%
+ {exercisesheets}
+\usepackage{varioref}
+\usepackage{hyperref}
+\usepackage{xcolor}
+
+%Usually the person responsible for the entire course:
+\author{Exampleauthor}
+\date{Example term/semester}
+\title{Introduction to Exercise Sheets Creation}
+\subject{Introduction to Exercise Sheets Creation}
+%Only used for beamer at the moment:
+\exshset{exauthor={Author of exercises}}
+
+\ifbeamer{
+ \exshset{beameruseblocks=false}
+}{
+ \exshset{
+ %default is \clearpage
+ sheet start page action={\pagebreak[3]\hrule},
+ sheet end page action={\vspace{4mm}\hrule\vspace{2cm}},
+ }
+}
+
+
+\exshset{solutions=true,
+task restate font={\color{black!60}},
+only={-}
+}
+
+
+\begin{document}
+
+%1
+\begin{sheet}[note={Learn how to create nice exercise sheets.},
+ date={Novanuar 42, -2022},title={First Sheet}]
+
+ \includeexercise*{exshexample-ex1}
+ \includeLexercise*{exshexample-ex2}
+
+ \begin{exercise}[points={many, many},firstline={Read the manual.}]
+ \end{exercise}
+
+ \begin{exercise}[points={sum},firstline={After you read the manual:}]
+ Play around with this example. You might want to read further manuals like:
+ \begin{enumerate}
+ %pointsfloatright should be usually set globally
+ \item\points[pointsfloatright]{2}pgf (for pgfkeys)
+ \item enumitem and similar \points[abbrev,bonus]{1}
+ \begin{enumerate}
+ \item paralist \thesubex
+ \item
+ \begin{enumerate}
+ \item varioref
+ \end{enumerate}
+ \end{enumerate}
+ \item all the others \points[inplace]{3} (why not?)
+ \label{subex:man2}
+ \end{enumerate}
+ \end{exercise}
+\end{sheet}
+
+%2
+\begin{sheet}[date={Novanuar 35, -2022}]
+ \begin{exercise}[points={many, many},
+ firstline={Read the manual.}]
+ \end{exercise}
+ \begin{solution}[framed,fragile]
+ Oh no, it's quite long.
+ \newframe
+ Really long, but please \verb|\relax|.
+ Ok, but my brain feels like:
+ \begin{verbatim}
+%
+ x
+ $ t
+&
+
+
+\
+#
+ \end{verbatim}
+ And yours?
+ \end{solution}
+\end{sheet}
+
+%3
+\begin{sheet}[date={Novanuar 28, -2022},title={Third Sheet},
+ number within sheet]
+ \begin{exercise}[points={many, many},
+ firstline={Read the manual.}]
+ \begin{solution}
+ OK, done.
+ \end{solution}
+ \end{exercise}
+\end{sheet}
+
+%4
+\begin{sheet}
+ \begin{Lexercise}
+ task = [[
+ This exercise will be skipped.
+ ]],
+ \end{Lexercise}
+ \begin{Lexercise}
+ task = [[
+ \label{ex:skiplex}%
+ This exercise will be skipped, but it has a reference.
+ ]],
+ subexercises = {[[\label{subex:skiplexOne} first]]},
+ \end{Lexercise}
+ \begin{exercise}[points={many, many},savetasks,
+ main task font={\tiny},subtask font={\itshape}
+ ]
+ \begin{maintask}
+ \label{ex:skipex} This exercise will be skipped
+ \end{maintask}
+% \begin{subtasks}
+% \item {first \label{subex:skipexOne}}
+% \subtask{second}
+% \end{subtasks}
+ \begin{enumerate}
+ \subtask {first \label{subex:skipexOne}}
+ \item {\label{subex:skipexTwo}} {12345}
+ \end{enumerate}
+
+ \end{exercise}
+\end{sheet}
+
+%5
+\begin{sheet}[date={Novanuar 21, -2022}]
+ \begin{exercise}[points={many, many},
+ firstline={Read the manual.}]
+ Observe how a sheet with title restarts the exercise numbering.
+ \begin{solution}[framed]
+ OK, done (again).
+ \newframe
+ Otherwise, I wouldn't know \textbackslash newframe now which
+ does not exist in beamer.
+ \end{solution}
+ \end{exercise}
+
+ Loading varioref enables you to refer to sub-exercises, like
+ this: Did you do \ref{subex:man2}? It is the subexercise
+ \subexnref{subex:man2} and has label \subexlref{subex:man2}.
+
+
+ \begin{exercise}[points={many, many},
+ firstline={Play around with the options.}]
+ Observe how a sheet with title restarts the exercise numbering.
+ \begin{solution}[defersolutiontitle]
+ \begin{frame}
+ This is a dual-use solution with explicit
+ beamer frames (and no framed).
+ \solutiontitle
+ Note, that we can freely place the title, because of
+ defersolutiontitle.
+ \end{frame}
+ \end{solution}
+ \end{exercise}
+
+ \begin{exercise}[points={many, many},beamersolution,
+ firstline={Play around with the options.}]
+ Observe how a sheet with title restarts the exercise numbering.
+ \begin{solution}
+ This solution is only shown if using the non-beamer version, because the option beamersolution was used. Otherwise both
+ solutions would be shown. You can set
+ the option beamersolution for individual (normal) solutions
+ to ignore some but not all solutions of an exercise.
+ \end{solution}
+ \begin{beamersolution}[defersolutiontitle]
+ \begin{frame}[t]
+ \solutiontitle
+ This beamersolution is only shown if using the beamer
+ version.
+ \end{frame}
+ \end{beamersolution}
+ \end{exercise}
+
+
+
+ \begin{exercise}[points={many, many},savetasks,
+ main task font={\tiny},subtask font={\itshape}
+ ]
+ \begin{maintask}
+ The exercise task can be saved and restated.
+ \end{maintask}
+ \begin{subtasks}
+ \subtask{first}
+ \begin{solution}[framed]
+ None (yet).
+ \end{solution}
+ \subtask{second}
+ \end{subtasks}
+ I forgot all the tasks!
+ \restatetask
+ Yeah, but what about the subtasks? I forgot the \restatetask[1] and the \restatetask[2] one. Or did I?
+ \end{exercise}
+
+ \begin{Lexercise}
+ --use [[]] if you need \ or escape it: "\\"
+ firstline = [[Assume $\pi=4$.]],
+ points=10,
+ name="Pragmatic",
+ options=[[main task font={\itshape}]],
+ task = [[
+ This is the main task specified via the Lua
+ interface, like subexercise \ref{subex:skiplexOne} in \ref{ex:skiplex}, whereas \ref{subex:skipexOne}
+ and \ref{subex:skipexTwo} in
+ \ref{ex:skipex} use the \LaTeX~interface.
+ ]],
+ solution=[[
+ This is a solution for the main task.
+ ]],
+ altsolutions={
+ {
+ name="Alternative Solution",
+ text="This is also a solution."
+ },{
+ idea=true,
+ text="This is also a solution."
+ }
+ },
+ \end{Lexercise}
+
+ \begin{Lexercise}
+ firstline = "Assume $e=3$.",
+ points="sum",
+ task = [[
+ This exercise has some subexercises. The Lua interface
+ computes point sums in a single pass.
+ ]],
+ subexercises = {
+ {
+ task = "First things first.",
+ bonuspoints = 4,
+ pointoptions = "abbrev",--passed to LaTeX interface
+ solution = [[None.]],
+ },{
+ task = "Second things afterwards.",
+ points = 16,
+ altsolutions = { [[None.]],[[Yet.]] },
+ }
+ }
+ \end{Lexercise}
+
+\end{sheet}
+
+\end{document}
+
diff --git a/exercisesheets.el b/exercisesheets.el
new file mode 100644
index 0000000..c446522
--- /dev/null
+++ b/exercisesheets.el
@@ -0,0 +1,113 @@
+;;; exercisesheets.el --- AUCTeX style for `exercisesheets.sty'
+;;
+;; Author: Sebastian Kuhnert <mail@sebastian-kuhnert.de>
+;; Created: 2009-11-18
+;; Keywords: tex
+;;
+;; This work may be distributed and/or modified under the conditions
+;; of the LaTeX Project Public License, either version 1.3c of this
+;; license or (at your option) any later version. The latest version
+;; of this license is in https://www.latex-project.org/lppl.txt and
+;; version 1.3c or later is part of all distributions of LaTeX
+;; version 2005/12/01 or later.
+;;
+;; This work has the LPPL maintenance status `maintained'.
+;;
+;; The Current Maintainer of this work is Sebastian Kuhnert.
+;;
+;; This work consists of the files listed in README.
+
+
+(defun LaTeX-exercisesheets-read-kwopt (context spec)
+ "Ask the user if/how an option should be included.
+
+CONTEXT is used in the prompt.
+
+SPEC is a string of the form
+`opt' for boolean options (ask if it should be included, default no),
+`!opt' for boolean options (ask if it should be included, default yes),
+`opt=' for free-form arguments for the option (include if non-empty),
+`!opt=' for free-form arguments for the option (always included),
+`opt=arg1,arg2,arg3' for suggestions with completion (empty means skip),
+`!opt=arg1,arg2,arg3' for suggestions with completion (always included),
+`opt=!arg1,arg2,arg3' for alternatives with completion (empty means skip),
+`!opt=!arg1,arg2,arg3' for alternatives with completion (always included).
+
+The result is the string to be used as argument. If the option is skipped, the result is nil."
+ (if (string-match "^\\(!?\\)\\(.*\\)=\\(!?\\)\\(.*\\)$" spec)
+ (let* ((required (if (match-string 1 spec) nil t))
+ (optstr (if required "optional " ""))
+ (require-match (if (match-string 3 spec) t nil))
+ (answer (save-match-data
+ (if (string= "" (match-string 4 spec))
+ (read-string (concat context ": " optstr "argument " (match-string 2 spec) "="))
+ (completing-read (concat context ": " optstr "argument " (match-string 2 spec) "=")
+ (split-string (match-string 4 spec) ",")
+ nil
+ require-match)))))
+ (if (or (not (string= "" answer)) required)
+ (if (string-match-p "[,= ]" answer)
+ (concat (match-string 2 spec) "={" answer "}")
+ (concat (match-string 2 spec) "=" answer))))
+ (if (string-match "^!\\(.*\\)$" spec)
+ (if (Y-or-n-p (concat context ": include argument " (match-string 1 spec) "? "))
+ (match-string 1 spec))
+ (if (y-or-N-p (concat context ": include argument " spec "? "))
+ spec))))
+
+(defun Y-or-n-p (query)
+ "Variant of `y-or-n-p' where return/enter means yes"
+ (let ((query-replace-map
+ (append '(keymap (return . act) (enter . act)) (cdr query-replace-map))))
+ (y-or-n-p query)))
+
+(defun y-or-N-p (query)
+ "Variant of `y-or-n-p' where return/enter means no"
+ (let ((query-replace-map
+ (append '(keymap (return . skip) (enter . skip)) (cdr query-replace-map))))
+ (y-or-n-p query)))
+
+(defun LaTeX-exercisesheets-read-kwopts(context startdelim enddelim &rest specs)
+ (let* ((anslist (mapcar
+ (lambda (spec) (LaTeX-exercisesheets-read-kwopt context spec))
+ args))
+ (ansstr (list-to-string (delq nil anslist) ",")))
+ (if (not (string= "" ansstr))
+ (concat startdelim ansstr enddelim))))
+
+(defun LaTeX-exercisesheets-insert-kwopts(optional &rest specs)
+ (if optional
+ (LaTeX-exercisesheets-read-kwopts(nil "[" "]" specs))
+ (LaTeX-exercisesheets-read-kwopts(nil "{" "}" specs))))
+
+(defun LaTeX-exercisesheets-insert-environment (env &rest args)
+ "Insert environment ENV considering keyword arguments specified by ARGS.
+
+See `LaTeX-exercisesheets-read-kwopt' for the format of the strings in ARGS."
+ (LaTeX-insert-environment env (LaTeX-exercisesheets-read-kwopts (concat env " environment") "[" "]" args)))
+
+(TeX-add-style-hook "exercisesheets"
+ (lambda ()
+ ;; New symbols
+ (TeX-add-symbols
+ '("subject" 1)
+ '("TODO" 0)
+ '("points" [ (LaTeX-exercisesheets-insert-kwopts "optional" "bonus") ] "points")
+ '("exshset" 1)
+ '("ifsolutions" 2))
+ ;; New environments
+ (LaTeX-add-environments
+ '("sheet" LaTeX-exercisesheets-insert-environment "date=" "note=" "title=")
+ '("exercise" LaTeX-exercisesheets-insert-environment "points=" "oral" "name=" "firstline=")
+ '("solution" LaTeX-exercisesheets-insert-environment "oral")
+ '("hint" LaTeX-exercisesheets-insert-environment "remark")
+ '("hint*" LaTeX-exercisesheets-insert-environment "remark"))
+ ;; Warning keywords
+ (font-latex-add-keywords '("TODO")
+ 'warning)
+ ))
+
+(defvar LaTeX-exercisesheets-package-options '("only=" "all" "solutions" "solutions=oral" "solutionsby=" "language=")
+ "Package options for the exercisesheets package.")
+
+;;; exercisesheets.el ends here
diff --git a/exercisesheets.sty b/exercisesheets.sty
new file mode 100644
index 0000000..1bd926c
--- /dev/null
+++ b/exercisesheets.sty
@@ -0,0 +1,1733 @@
+%% exercisesheets.sty
+%% Copyright 2008-2022 Sebastian Kuhnert, Frank Fuhlbrück
+%
+% This work may be distributed and/or modified under the conditions
+% of the LaTeX Project Public License, either version 1.3c of this
+% license or (at your option) any later version. The latest version
+% of this license is in https://www.latex-project.org/lppl.txt and
+% version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Frank Fuhlbrück.
+%
+% This work consists of the files listed in README.
+
+
+%\NeedsTeXFormat{LaTeX2e}[1994/12/01]
+
+% don't forget to update the version and date in exercisesheets.tex
+\def\exsh@version{0.12}
+\def\exsh@date{2022/09/02}
+
+\ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
+\message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>}
+
+% TODO: fix "above hint skip"
+
+
+\RequirePackage{etoolbox}%[2008/06/28]
+\RequirePackage{scrlfile}
+\RequirePackage{environ}
+
+\RequirePackage{pgfkeys}
+\RequirePackage{keyval}
+\RequirePackage{kvoptions}
+
+\RequirePackage{ifthen}
+\RequirePackage{ifluatex}
+
+\RequirePackage{amsmath}
+
+\RequirePackage{currfile}
+\RequirePackage{catchfile}
+
+%we need getrefnumber
+\RequirePackage{refcount}
+
+% configuration keys
+
+\newif\ifexsh@beamer
+\@ifclassloaded{beamer}{\exsh@beamertrue}{}
+
+\newif\ifexsh@patchenumerate\exsh@patchenumeratetrue
+\newif\ifexsh@savetasks
+\newif\ifexsh@solutions
+\newif\ifexsh@oralsolutions
+\newif\ifexsh@nonoralsolutions
+\newif\ifexsh@samplesolutions
+\newif\ifexsh@exnumsheet
+\newif\ifexsh@forcesample %force printing sample sol. of wrong type
+%For beamer only
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\ifexsh@beamer
+\newif\ifexsh@beamerwithheadline
+\newif\ifexsh@beamerwithfootline
+\newif\ifexsh@beameruseblocks
+\newif\ifexsh@defersolutiontitle
+\newif\ifexsh@framed
+\newif\ifexsh@fragile
+\fi
+%Also only true for beamer, but we want to use it elsewhere
+\newif\ifexsh@beamersolution
+%%
+\newif\ifexsh@gradingguides
+\newif\ifexsh@inplace
+\newif\ifexsh@sample
+\newif\ifexsh@hide%currently only set via sample in exercise env.
+\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
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+ %currently we do nothing if beamer is loaded,
+ %but this might change
+\else%--------- NON-BEAMER: ---------------------------------------
+ \let\pause\relax
+ \def\frame{}
+ \renewcommand{\frame}[1][]{}
+ \let\endframe\relax
+ \def\onslide<##1>{}
+ \def\only<##1>##2{##2}
+ \def\uncover<##1>##2{##2}
+ \def\visible<##1>##2{##2}
+ \def\invisible<##1>##2{##2}
+ \long\def\alt<##1>##2##3{##2}
+ \long\def\temporal<##1>##2##3##4{##3}
+ \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}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \exsh@beamercompatdonetrue
+\fi
+}
+
+\pgfkeys{/exsh/.is family,/exsh,
+ patchenumerate/.is if=exsh@patchenumerate,
+ patchenumerate/.default=true,
+ savetasks/.is if=exsh@savetasks,
+ savetasks/.default=true,
+ solutions/.is choice,
+ solutions/true/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionstrue,
+ solutions/oral/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionsfalse,
+ solutions/nonoral/.code=\exsh@solutionstrue\exsh@oralsolutionsfalse\exsh@nonoralsolutionstrue,
+ solutions/sample nonoral/.code=\exsh@solutionstrue\exsh@oralsolutionsfalse\exsh@nonoralsolutionstrue\exsh@samplesolutionstrue,
+ solutions/sample oral/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionsfalse\exsh@samplesolutionstrue,
+ solutions/sample all/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionstrue\exsh@samplesolutionstrue,
+ solutions/false/.code=\exsh@solutionsfalse\exsh@oralsolutionsfalse\exsh@nonoralsolutionsfalse,
+ solutions/.default=true,
+ number within sheet/.is if=exsh@exnumsheet,
+ number within sheet/.default=true,
+ forcesample/.is if=exsh@forcesample,
+ forcesample/.default=true,
+ gradingguides/.is if=exsh@gradingguides,
+ gradingguides/.default=true,
+ only/.initial={-},
+ all/.style={/exsh/only={-}},all/.value forbidden,
+ solutionsby/.code={\def\exsh@solutionsby{#1}},
+ solutionsby/.value required,
+ exercisespath/.code={\def\exsh@exercisespath{#1}},
+ exercisespath/.value required,
+ bonus/.is if=exsh@bonus,
+ bonus/.default=true,
+ inplace/.is if=exsh@inplace,
+ 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,
+ pointsfloatright/.default=true,
+ abbrev/.is if=exsh@abbrev,
+ abbrev/.default=true,
+ beamercompatibility/.default={ignore},
+ beamercompatibility/.initial={ignore},
+ beamercompatibility/.code={\exsh@beamercompatibility}
+}
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\pgfkeys{exsh,
+ beamerwithheadline/.is if=exsh@beamerwithheadline,
+ beamerwithheadline/.default=true,
+ beamerwithfootline/.is if=exsh@beamerwithfootline,
+ beamerwithfootline/.default=true,
+ beameruseblocks/.is if=exsh@beameruseblocks,
+ beameruseblocks/.default=true,
+ beamersolution/.is if=exsh@beamersolution,
+ beamersolution/.default=true,
+ defersolutiontitle/.is if=exsh@defersolutiontitle,
+ defersolutiontitle/.default=true,
+ framed/.is if=exsh@framed,
+ framed/.default=true,
+ fragile/.is if=exsh@fragile,
+ fragile/.default=true,
+ beamersolution/.initial={false},
+ beamerwithheadline/.initial={false},
+ beamerwithfootline/.initial={false},
+ beameruseblocks/.initial={false},
+ defersolutiontitle/.initial={false},
+ framed/.initial={false},
+}
+\else%--------- NON-BEAMER: ---------------------------------------
+\pgfkeys{exsh,
+ beamerwithheadline/.default={ignore},
+ beamerwithheadline/.initial={ignore},
+ beamerwithfootline/.default={ignore},
+ beamerwithfootline/.initial={ignore},
+ beamersolution/.default={ignore},
+ beamersolution/.initial={ignore},
+ defersolutiontitle/.default={ignore},
+ defersolutiontitle/.initial={ignore},
+ framed/.default={ignore},
+ framed/.initial={ignore},
+ framed/.code={\let\newframe\relax},
+ fragile/.default={ignore},
+ fragile/.initial={ignore},
+}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% store title data for sheet headers
+\ifundef\subject{% \subject is only provided by KOMA classes
+ \newcommand{\subject}[1]{}%
+ \def\@subject{}%
+}{}
+% beamer has subject, but not \@subject:
+\providecommand{\@subject}{}
+\apptocmd{\subject}{\pgfkeys{/exsh/subject={#1}}}{}{}%
+\ifdefempty{\@subject}{
+ \pgfkeys{exsh,subject/.initial={\PackageWarning{exercisesheets}{No \string\subject\space given}}}
+}{
+ \pgfkeys{/exsh/subject/.initial/.expand once=\@subject}
+}
+\ifdefstring{\@date}{\today}{
+ \pgfkeys{/exsh/semester/.initial={\PackageWarning{exercisesheets}{No semester given in \string\date}}}
+}{
+ \pgfkeys{/exsh/semester/.initial/.expand once=\@date}
+}
+\let\@exsh@origdate\date
+\renewcommand{\date}[1]{\@exsh@origdate{#1}\pgfkeys{/exsh/semester={#1}}}
+% this breaks (likely because of detokenization):
+% -> missing \begin{document}
+% \apptocmd{\date}{\pgfkeys{/exsh/semester={#1}}}{}{}
+\pgfkeys{/exsh/author/.code={%
+ \def\exsh@author{#1}%
+ \def\exsh@repeat{1}%
+ \loop\ifnum\exsh@repeat>0
+ \def\exsh@repeat{0}%
+ \patchcmd{\exsh@author}{\and}{, }{\def\exsh@repeat{1}}{}%
+ \repeat
+ },
+ /exsh/author/.expand once=\@author}
+\let\exsh@oldauthor\author
+\def\author#1{\exsh@oldauthor{#1}\pgfkeys{/exsh/author={#1}}}
+
+% helper macro for automatic language selection
+\newif\ifexsh@provideonly
+\def\exsh@deforprovide#1#2{%
+ \ifthenelse{\(\NOT\boolean{exsh@provideonly}\)
+ \OR \equal{}{\pgfkeysvalueof{#1}}}{%
+ \pgfkeys{#1=#2}%
+ }{}%
+}
+
+\pgfkeys{exsh,
+ %general package options
+ patchenumerate/.initial=true,
+ custom skip macro/.initial=\exsh@skipcustomstuff,
+ showtodos/.initial={false},
+ hidetodos/.style={/exsh/showtodos=false},
+ hidetodos/.value forbidden,
+ % additional sheet info
+ title/.initial={},
+ date/.initial={},
+ note/.initial={},
+ exauthor/.initial={\exsh@author},
+ number within sheet/.initial={false},
+ %
+ % additional exercise info
+ name/.initial={},
+ forcesample/.initial={false},
+ firstline/.initial={},
+ points/.initial={},
+ oral/.style={/exsh/points=oral},oral/.value forbidden,
+ inplace/.initial={false},
+ sample/.initial={false},
+ filenameasexercisename/.initial={false},
+ pointsfloatright/.initial={false},
+ bonus/.initial={false},
+ nobonus/.style={/exsh/bonus=false},nobonus/.value forbidden,
+ abbrev/.initial={false},
+ noabbrev/.style={/exsh/abbrev=false},noabbrev/.value forbidden,
+ pointsinfo/.initial={},
+ optional/.style={/exsh/pointsinfo=\ifexsh@abbrev%
+ \pgfkeysvalueof{/exsh/strings/optional abbrev}%
+ \else%
+ \pgfkeysvalueof{/exsh/strings/optional}%
+ \fi},
+ optional/.value forbidden,
+ exercisemark/.initial={},
+ difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden,
+ savetasks/.initial=false,
+}
+\pgfkeys{exsh,
+ %
+ % translatable strings
+ strings/sheet/.initial={},
+ strings/sheets/.initial={},
+ strings/solutions/.initial={},
+ strings/solutionsby/.initial={},
+ strings/gradingguide/.initial={},
+ strings/exercise/.initial={},
+ strings/solution/.initial={},
+ strings/idea/.initial={},
+ strings/hint/.initial={},
+ strings/remark/.initial={},
+ strings/oral/.initial={},
+ strings/oral abbrev/.initial={},
+ strings/point/.initial={},
+ strings/points/.initial={},
+ strings/points abbrev/.initial={},
+ strings/bonus point/.initial={},
+ strings/bonus points/.initial={},
+ strings/bonus points abbrev/.initial={},
+ strings/optional/.initial={},
+ strings/optional abbrev/.initial={},
+ %
+ % languages: predifined string sets
+ language/.is choice,
+ language/german/.code={%
+ \exsh@deforprovide{/exsh/strings/sheet} {\"Ubungsblatt}%
+ \exsh@deforprovide{/exsh/strings/sheets} {\"Ubungsbl\"atter}%
+ \exsh@deforprovide{/exsh/strings/solutions} {L\"osungsvorschl\"age}%
+ \exsh@deforprovide{/exsh/strings/solutionsby} {L\"osungen von}%
+ \exsh@deforprovide{/exsh/strings/gradingguide}{Bepunktung}%
+ \exsh@deforprovide{/exsh/strings/exercise} {Aufgabe}%
+ \exsh@deforprovide{/exsh/strings/solution} {L\"osung}%
+ \exsh@deforprovide{/exsh/strings/idea} {L\"osungsidee}%
+ \exsh@deforprovide{/exsh/strings/hint} {Hinweis}%
+ \exsh@deforprovide{/exsh/strings/remark} {Bemerkung}%
+ \exsh@deforprovide{/exsh/strings/oral} {m\"undlich}%
+ \exsh@deforprovide{/exsh/strings/oral abbrev} {mdl.}%
+ \exsh@deforprovide{/exsh/strings/point} {Punkt}%
+ \exsh@deforprovide{/exsh/strings/points} {Punkte}%
+ \exsh@deforprovide{/exsh/strings/points abbrev}{P.}%
+ \exsh@deforprovide{/exsh/strings/bonus point} {Zusatzpunkt}%
+ \exsh@deforprovide{/exsh/strings/bonus points}{Zusatzpunkte}%
+ \exsh@deforprovide{/exsh/strings/bonus points abbrev}{ZP.}%
+ \exsh@deforprovide{/exsh/strings/optional} {optional}%
+ \exsh@deforprovide{/exsh/strings/optional abbrev} {opt.}%
+ },language/german/.value forbidden,
+ language/ngerman/.style={/exsh/language/german=#1},
+ language/english/.code={%
+ \exsh@deforprovide{/exsh/strings/sheet} {Exercise Sheet}%
+ \exsh@deforprovide{/exsh/strings/sheets} {Exercise Sheets}%
+ \exsh@deforprovide{/exsh/strings/solutions} {Suggested Solutions}%
+ \exsh@deforprovide{/exsh/strings/solutionsby} {Solutions by}%
+ \exsh@deforprovide{/exsh/strings/gradingguide}{Grading guideline}%
+ \exsh@deforprovide{/exsh/strings/exercise} {Exercise}%
+ \exsh@deforprovide{/exsh/strings/solution} {Solution}%
+ \exsh@deforprovide{/exsh/strings/idea} {Idea for solution}%
+ \exsh@deforprovide{/exsh/strings/hint} {Hint}%
+ \exsh@deforprovide{/exsh/strings/remark} {Remark}%
+ \exsh@deforprovide{/exsh/strings/oral} {oral}%
+ \exsh@deforprovide{/exsh/strings/oral abbrev} {oral}%
+ \exsh@deforprovide{/exsh/strings/point} {point}%
+ \exsh@deforprovide{/exsh/strings/points} {points}%
+ \exsh@deforprovide{/exsh/strings/points abbrev}{p.}%
+ \exsh@deforprovide{/exsh/strings/bonus point} {bonus point}%
+ \exsh@deforprovide{/exsh/strings/bonus points}{bonus points}%
+ \exsh@deforprovide{/exsh/strings/bonus points abbrev}{b.p.}%
+ \exsh@deforprovide{/exsh/strings/optional} {optional}%
+ \exsh@deforprovide{/exsh/strings/optional abbrev} {opt.}%
+ },language/english/.value forbidden,
+ language/.unknown/.code={%
+ \PackageWarning{exercisesheets}{Unknown language \pgfkeyscurrentname.
+ Defaulting to English.}{}%
+ \pgfkeys{/exsh/language=english}%
+ },
+ %
+ % alternate strings
+ idea/.style={/exsh/strings/solution=\pgfkeysvalueof{/exsh/strings/idea}},
+ remark/.style={/exsh/strings/hint=\pgfkeysvalueof{/exsh/strings/remark}},
+ %
+ % hooks
+ every sheet/.code={},
+ every exercise/.code={},
+ every solution/.code={},
+ every hint/.code={},
+ %
+ % font specifications
+ sheet header font/.initial=\normalfont\normalsize,
+ subject font/.initial=\scshape,
+ author font/.initial=\scshape,
+ semester font/.initial={},
+ date font/.initial={},
+ solutionsby font/.initial=\itshape,
+ sheet note font/.initial=\itshape\bfseries,
+ sheet title font/.initial=\Large\bfseries,
+ exercise title font/.initial=\bfseries,
+ points font/.initial=\itshape,
+ main task font/.initial={},
+ subtask font/.initial={},
+ task restate font/.initial=\itshape,
+ hint font/.initial={},
+ hint title font/.initial=\itshape,
+ solution font/.initial={},
+ solution title font/.initial=\bfseries,
+ grading guide font/.initial=\itshape,
+ todo marker font/.initial=\ifdef{\color}{\color{red}}{}\bfseries,
+ %
+ % skip values
+ below slide headline skip/.initial={0mm},
+ above sheet title skip/.initial={4ex},
+ above sheet note skip/.initial={.7ex},
+ above solutionsby skip/.initial={1ex},
+ below sheet header skip/.initial={4ex plus 1ex minus .5ex},
+ above exercise skip/.initial={3ex plus 1ex minus .5em},
+ below exercise title skip/.initial={\parskip},
+ above solution skip/.initial={1ex},
+ above hint skip/.initial={1ex},
+ %
+ % page handling
+ sheet start page action/.initial={\clearpage},
+ sheet end page action/.initial={\clearpage},
+ %
+ % conditionals
+ ifsolutions/.code 2 args={\ifsolutions{\pgfkeysalso{#1}}{\pgfkeysalso{#2}}},
+ iforalsolutions/.code 2 args={\iforalsolutions{\pgfkeysalso{#1}}{\pgfkeysalso{#2}}},
+ ifnonoralsolutions/.code 2 args={\ifnonoralsolutions{\pgfkeysalso{#1}}{\pgfkeysalso{#2}}},
+}
+
+% default values
+\pgfkeys{exsh,solutions=false,all}
+
+% process package options
+\@expandtwoargs\pgfqkeys{/exsh}{\csname opt@exercisesheets.sty\endcsname}
+
+% mark options as processed
+\expandafter\undef\csname opt@exercisesheets.sty\endcsname
+
+% allow further keys to be set
+\def\exshset#1{\pgfkeys{exsh,#1}}
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-ONLY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\define@key{beamerframe}{t}[true]{% top
+ \beamer@frametopskip=-2pt\relax%
+ \beamer@framebottomskip=0pt plus 1fill\relax%
+ \beamer@frametopskipautobreak=\beamer@frametopskip\relax%
+ \beamer@framebottomskipautobreak=\beamer@framebottomskip\relax%
+}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-ONLY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% automatic language selection
+\AfterEndPreamble{%
+ \exsh@provideonlytrue
+ \ifdef{\bbl@main@language}{%
+ \pgfkeys{/exsh/language=\bbl@main@language}%
+ }{%
+ \pgfkeys{/exsh/language=english}%
+ }%
+ \exsh@provideonlyfalse
+}%
+
+% range checks
+\newif\ifexsh@isinrange
+\newif\ifexsh@singularrange
+\def\exsh@checkrange#1{%
+ \edef\exsh@range@entry{#1}%
+ \def\exsh@range@curstart{}%
+ \exsh@isinrangefalse
+ \exsh@singularrangetrue
+ \pgfkeysgetvalue{/exsh/only}{\exsh@temp}%
+ \ifthenelse{\equal{-}{\exsh@temp}}{%
+ \exsh@isinrangetrue
+ \ifnumequal{\exsh@lastsheet}{1}{%
+ \exsh@singularrangetrue
+ }{%
+ \exsh@singularrangefalse
+ }%
+ }{%
+ \expandafter\exsh@range@parsestart\exsh@temp\exsh@range@end
+ }%
+}
+\def\exsh@range@parsestart#1{%
+ \ifstrequal{#1}{,}{%
+ \exsh@singularrangefalse
+ \ifdefstring{\exsh@range@curstart}{last}{%
+ \let\exsh@range@curstart\exsh@lastsheet
+ }{}%
+ \ifdefequal{\exsh@range@entry}{\exsh@range@curstart}{%
+ \exsh@isinrangetrue
+ }{}%
+ \def\exsh@range@curstart{}%
+ \exsh@range@parsestart
+ }{%
+ \ifstrequal{#1}{\exsh@range@end}{%
+ \ifdefstring{\exsh@range@curstart}{last}{%
+ \let\exsh@range@curstart\exsh@lastsheet
+ }{}%
+ \ifdefequal{\exsh@range@entry}{\exsh@range@curstart}{%
+ \exsh@isinrangetrue
+ }{}%
+ }{%
+ \ifdefequal{#1}{-}{%
+ \exsh@singularrangefalse
+ \ifdefstring{\exsh@range@curstart}{}{%
+ \def\exsh@range@curstart{0}%
+ }{}%
+ \ifdefstring{\exsh@range@curstart}{last}{%
+ \let\exsh@range@curstart\exsh@lastsheet
+ }{}%
+ \def\exsh@range@curend{}%
+ \exsh@range@parseend
+ }{%
+ \appto{\exsh@range@curstart}{#1}%
+ \exsh@range@parsestart
+ }%
+ }%
+ }%
+}
+\def\exsh@range@parseend#1{%
+ \ifstrequal{#1}{,}{%
+ \ifdefstring{\exsh@range@curend}{last}{%
+ \def\exsh@range@curend{10000}%
+ }{}%
+ \ifdefstring{\exsh@range@curend}{}{
+ \def\exsh@range@curend{10000}%
+ }{}%
+ \ifthenelse{\NOT \(\exsh@range@curstart > \exsh@range@entry
+ \OR \exsh@range@entry > \exsh@range@curend\)}{%
+ \exsh@isinrangetrue
+ }{}%
+ \def\exsh@range@curstart{}%
+ \exsh@range@parsestart
+ }{%
+ \ifstrequal{#1}{\exsh@range@end}{%
+ \ifdefstring{\exsh@range@curend}{last}{%
+ \def\exsh@range@curend{10000}%
+ }{}%
+ \ifdefstring{\exsh@range@curend}{}{
+ \def\exsh@range@curend{10000}%
+ }{}%
+ \ifthenelse{\NOT \(\exsh@range@curstart > \exsh@range@entry
+ \OR \exsh@range@entry > \exsh@range@curend\)}{%
+ \exsh@isinrangetrue
+ }{%
+ }%
+ }{%
+ \appto{\exsh@range@curend}{#1}%
+ \exsh@range@parseend
+ }%
+ }%
+}
+
+% remember last sheet (for range checks)
+\def\exsh@lastsheet{0}% to be overridden in aux file
+\AtEndDocument{%
+ \immediate\write\@auxout{\string\gdef\string\exsh@lastsheet{\arabic{part}}}%
+}
+
+\numberwithin{page}{part}
+\renewcommand{\thepage}{\arabic{page}}%changed for every sheet
+\setcounter{secnumdepth}{-1}
+
+\AfterPackage*{hyperref}{%
+ % make PDF destinations unique:
+ \def\theHsection{\arabic{sheetid}.\arabic{section}}%
+ \def\theHpage{\arabic{sheetid}-\arabic{page}}%
+ %
+ % open bookmarks when typesetting a single sheet
+ \AtEndPreamble{%
+ \exsh@checkrange{0}%
+ \ifexsh@singularrange\hypersetup{bookmarksopen}\fi
+ }%
+}
+
+% automatic title selection
+\let\exsh@title\relax
+\let\exsh@title@new\relax
+\def\exsh@write@title#1{%
+ \xdef\exsh@title@new{\expandonce #1}%
+ \protected@write\@auxout{}{\string\gdef\string\exsh@title{\expandonce\exsh@title@new}}%
+}
+\AfterEndDocument{%
+ \ifthenelse{\equal{\exsh@title}{\exsh@title@new}}{}{%
+ \@latex@warning@no@line{Label(s) may have changed.
+ Rerun to get cross-references right}%
+ }%
+}
+\AfterEndPreamble{%
+ \exsh@checkrange{0}%
+ \ifexsh@singularrange\else
+ \pgfkeysgetvalue{/exsh/strings/sheets}{\exsh@tmp}%
+ \exsh@write@title{\exsh@tmp}%
+ \fi
+}
+
+\AtBeginDocument{%
+ \ifexsh@solutions
+ \title{\exsh@title: \pgfkeysvalueof{/exsh/strings/solutions}}%
+ \else
+ \title{\exsh@title}
+ \fi
+}
+\newcounter{sheetid}% only used to disambiguate hyperref labels
+\newenvironment{sheet}[1][]{%
+ \pgfkeys{exsh,every sheet,#1}%
+% \pgfkeysvalueof{/exsh/sheet start page action}%
+ \stepcounter{sheetid}%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/title}}}{%
+ \numdef\exsh@tmp{\value{part}+1}%
+ \edef\exsh@temp{\expandonce{\pgfkeysvalueof{/exsh/strings/sheet}}\noexpand~\exsh@tmp}%
+ \pgfkeys{/exsh/title/.expand once={\exsh@temp}}%
+ \def\thepage{\arabic{part}-\arabic{page}}%
+ }{%
+ \def\thepage{\arabic{page}}%
+ }%
+ \ifexsh@exnumsheet
+ \edef\exsh@exnumstore{\arabic{section}}
+ \setcounter{section}{0}%
+ \fi
+ \numdef\exsh@tmp{\value{part}+1}%
+ \exsh@checkrange{\exsh@tmp}%
+ \ifexsh@isinrange
+ \ifexsh@singularrange
+ \pgfkeysgetvalue{/exsh/title}{\exsh@temp}%
+ \exsh@write@title{\exsh@temp}%
+ \fi
+ \exsh@sheethead
+ \else
+ \refstepcounter{part}%
+ \def\exsh@skipwhat{sheet}\expandafter\exsh@skipstuff
+ \fi
+}{%
+ \par
+ \begingroup
+ \ifnum\value{page}=1\thispagestyle{empty}\fi
+ \ifexsh@isinrange
+ \pgfkeysvalueof{/exsh/sheet end page action}%
+ \fi
+ \endgroup
+ \ifexsh@exnumsheet
+ \setcounter{section}{\exsh@exnumstore}%
+ \fi
+}
+\listadd{\exsh@enums}{enumerate}
+\listadd{\exsh@enums}{compactenum}
+\listadd{\exsh@enums}{asparaenum}
+\listadd{\exsh@enums}{inparaenum}
+\listadd{\exsh@enums}{subtasks}
+\listadd{\exsh@nonenums}{itemize}
+\listadd{\exsh@nonenums}{compactitem}
+\listadd{\exsh@nonenums}{asparaitem}
+\listadd{\exsh@nonenums}{inparaitem}
+\listadd{\exsh@nonenums}{description}
+\listadd{\exsh@nonenums}{compactdesc}
+\listadd{\exsh@nonenums}{asparadesc}
+\listadd{\exsh@nonenums}{inparadesc}
+\listadd{\exsh@nonenums}{asparablank}
+\listadd{\exsh@nonenums}{inparablank}
+\listadd{\exsh@nonenums}{list}
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+ \let\exsh@hyper@itemtrue\relax
+\else%--------- NON-BEAMER: ---------------------------------------
+ \def\exsh@hyper@itemtrue{\@hyper@itemtrue}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%TODO: We need some proper switch-case here
+%evaluate csname/csdef+detokenize
+\ExplSyntaxOn
+\cs_new_eq:NN \exsh@ifsingletoken \tl_if_single_token:nTF
+\ExplSyntaxOff
+\long\def\exsh@skipstuff#1{%
+ \exsh@ifsingletoken{#1}{%
+ \ifstrequal{#1}{\begin}{\exsh@skipstuff@begin}{%
+ \ifstrequal{#1}{\end}{\exsh@skipstuff@end}{%
+ \ifstrequal{#1}{\includeexercise}{\exsh@skipstuff@incex}{%
+ \ifstrequal{#1}{\includeLexercise}{\exsh@skipstuff@incLex}{%
+ \ifstrequal{#1}{\label}{\exsh@skipstuff@label}{%
+ \ifstrequal{#1}{\subtask}{\exsh@skipstuff@subtask}{%
+ \ifstrequal{#1}{\input}{\exsh@skipstuff@input}{%
+ \ifstrequal{#1}{\exsh@skipstuff@endfile}{\currfile@pop\exsh@skipstuff}{%
+ \ifstrequal{#1}{\setcounter}{\expandafter\exsh@skipstuff\setcounter}{%
+ \ifstrequal{#1}{\item}{\ifdef{\@enumctr}{\exsh@hyper@itemtrue\refstepcounter{\@enumctr}}{}}{}%
+ \pgfkeysvalueof{/exsh/custom skip macro}{#1}}}}}}}}}}%
+ }{%
+ \exsh@skipstuff#1%
+ }%
+}%
+\let\exshskipcontinue\exsh@skipstuff
+\long\def\exsh@skipcustomstuff#1{\exshskipcontinue}
+\def\exsh@skipstuff@end#1{%
+ \expandafter\ifstrequal\expandafter{\exsh@skipwhat}{#1}{%
+ \expandafter\end\expandafter{\exsh@skipwhat}%
+ \let\exsh@skipwhat\relax%
+ }{
+ \endgroup\exsh@skipstuff%
+ }%
+}
+\def\exsh@skipstuff@begin#1{%
+ \begingroup
+ \ifstrequal{#1}{Lexercise}{\exsh@skipstuff@Lexercise}{%
+ \ifstrequal{#1}{exercise}{\refstepcounter{section}%
+ % automatic label for the first exercise in every included file
+ \ifthenelse{\equal{\jobname}{\currfilebase}}{}{%
+ \ifcsdef{exsh@autolabel@\currfilebase}{}{%
+ \csdef{exsh@autolabel@\currfilebase}{}%
+ \exsh@autolabel{ex:\currfilebase}}}%
+ }{}%
+ \ifinlist{#1}{\exsh@enums}{%
+ \exsh@skipstuff@beginenum
+ }{%
+ \ifinlist{#1}{\exsh@nonenums}{%
+ \undef\@enumctr
+ }{}%
+ \exsh@skipstuff
+ }%
+ }%
+}
+\def\exsh@skipstuff@beginenum{%
+ \ifnum\@enumdepth>\thr@@
+ \@toodeep
+ \else
+ \advance\@enumdepth\@ne
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \setcounter{\@enumctr}{0}%
+ \fi
+ \@ifundefined{@enumlabel@}{%
+ \exsh@skipstuff
+ }{%
+ \@ifnextchar[{\@enumlabel@{\exsh@skipstuff}[}{\exsh@skipstuff}%
+ }%
+}
+\def\exsh@skipstuff@label#1{%
+ % Locally modify \protected@write to use \immediate\write instead.
+ % This is needed to include labels after the last shipout in the aux file.
+ \begingroup
+ \def\protected@write##1##2##3{%
+ \begingroup
+ \let\protect\@unexpandable@protect
+ \immediate\write##1{##3}%
+ \endgroup
+ }%
+ \label{#1}%
+ \endgroup
+ \exsh@skipstuff
+}
+\def\exsh@skipstuff@subtask#1{%
+ \exsh@skipstuff \item #1
+}
+\def\exsh@skipstuff@input#1{%
+ \CatchFileDef{\exsh@inputfilecontent}{#1}{}%
+ \currfile@push
+ \currfile@set{#1}%
+ \expandafter\exsh@skipstuff\exsh@inputfilecontent\exsh@skipstuff@endfile
+}
+
+\def\exsh@skipstuff@incex{%
+ \@ifstar\exsh@skipstuff@incex@@\exsh@skipstuff@incex@%
+}
+
+\newcommand{\exsh@skipstuff@incex@}[2][]{%
+ \exsh@skipstuff\input{%
+ \ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}#2}%
+}
+
+\newcommand{\exsh@skipstuff@incex@@}[2][]{%
+ \refstepcounter{section}
+ \exsh@autolabel{ex:#2}
+ \exsh@skipstuff
+}
+
+\def\exsh@skipstuff@incLex{%
+ \@ifstar\exsh@skipstuff@incLex@@\exsh@skipstuff@incLex@%
+}
+
+\newcommand{\exsh@skipstuff@incLex@}[2][]{%
+ \exsh@dlua{
+ local prefix =
+ "\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}"
+ exsh_cur_exercise=dofile(prefix .. "#2.lua")
+ }%
+ \expandafter\exsh@skipstuff%
+ \exsh@dlua{exsh_texprintlines(exsh_cur_exercise)}%
+}
+
+\let\exsh@skipstuff@incLex@@\exsh@skipstuff@incex@@
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\def\exsh@sheethead{%
+ \pgfkeysvalueof{/exsh/sheet start page action}%
+ \pgfkeysgetvalue{/exsh/title}{\exsh@tmp}%
+ \ifexsh@solutions
+ \expandafter\edef\expandafter\exsh@tmp{\expandonce\exsh@tmp:\noexpand~\pgfkeysvalueof{/exsh/strings/solutions}}%
+ \fi
+ \refstepcounter{part}%
+ \begin{frame}
+ \begin{block}{}
+ \centering\Large\exsh@tmp
+ \end{block}
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet header font}%
+ \ifexsh@solutions%
+ \ifdefvoid{\exsh@solutionsby}{}{%
+ \begingroup
+ \begin{block}{}
+ \pgfkeysvalueof{/exsh/solutionsby font}%
+ \vskip\pgfkeysvalueof{/exsh/above solutionsby skip}%
+ \relax%
+ \pgfkeysvalueof{/exsh/strings/solutionsby}%
+ ~\exsh@solutionsby\\\unskip%
+ \end{block}%
+ \endgroup
+ }%
+ \else
+ \fi
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/note}}}{%
+ }{%
+ \ifbool{exsh@samplesolutions}{}{%
+ \begingroup
+ \begin{block}{}
+ \pgfkeysvalueof{/exsh/sheet note font}%
+ \vskip\pgfkeysvalueof{/exsh/above sheet note skip}\relax
+ \pgfkeysvalueof{/exsh/note}\\\unskip%
+ \end{block}%
+ \endgroup
+ }%
+ }%
+ \endgroup
+% \stepcounter{page}%
+ \end{frame}
+}
+\else%--------- NON-BEAMER: ---------------------------------------
+\def\exsh@sheethead{%
+ \pgfkeysvalueof{/exsh/sheet start page action}%
+ \pgfkeysgetvalue{/exsh/title}{\exsh@tmp}%
+ \ifexsh@solutions
+ \expandafter\edef\expandafter\exsh@tmp{\expandonce\exsh@tmp:\noexpand~\pgfkeysvalueof{/exsh/strings/solutions}}%
+ \fi
+ \refstepcounter{part}%
+ \part[\pgfkeysvalueof{/exsh/title}]{\normalsize
+ \pgfkeysvalueof{/exsh/sheet header font}\centering%
+ \begingroup\raggedright%
+ {\pgfkeysvalueof{/exsh/subject font}\pgfkeysvalueof{/exsh/subject}}\hfill
+ {\pgfkeysvalueof{/exsh/semester font}\pgfkeysvalueof{/exsh/semester}}\\
+ {\pgfkeysvalueof{/exsh/author font}\exsh@author}\hfill
+ {\pgfkeysvalueof{/exsh/date font}\pgfkeysvalueof{/exsh/date}}\\
+ \vskip\pgfkeysvalueof{/exsh/above sheet title skip}\relax%
+ \endgroup
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet title font}\exsh@tmp\\\unskip
+ \endgroup
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet header font}%
+ \ifexsh@solutions%
+ \ifdefvoid{\exsh@solutionsby}{}{%
+ \begingroup
+ \pgfkeysvalueof{/exsh/solutionsby font}%
+ \vskip\pgfkeysvalueof{/exsh/above solutionsby skip}\relax
+ \pgfkeysvalueof{/exsh/strings/solutionsby}~\exsh@solutionsby\\\unskip%
+ \endgroup
+ }%
+ \else
+ \fi
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/note}}}{%
+ }{%
+ \ifbool{exsh@samplesolutions}{}{%
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet note font}%
+ \vskip\pgfkeysvalueof{/exsh/above sheet note skip}\relax
+ \pgfkeysvalueof{/exsh/note}\\\unskip%
+ \endgroup
+ }%
+ }%
+ \endgroup
+ }%
+ \unskip
+ \vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax
+ \stepcounter{page}%
+}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\ifdef{\othersectionslevelsformat}{%
+ \renewcommand{\othersectionlevelsformat}[1]{%
+ \ifstrequal{#1}{section}%
+ {}%
+ {\csname the#1\endcsname\autodot\enskip}}%
+}{}
+
+%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}
+\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{}%
+ }{%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/points}}}{%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/pointsinfo}}%
+ }{%
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifexsh@abbrev%
+ \pgfkeysgetvalue{/exsh/strings/oral abbrev}{\exsh@points}%
+ \else%
+ \pgfkeysgetvalue{/exsh/strings/oral}{\exsh@points}%
+ \fi%
+ }{%
+ \ifexsh@abbrev%
+ \ifexsh@bonus%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/bonus points abbrev}}%
+ \else%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points abbrev}}%
+ \fi%
+ \else%
+ \ifthenelse{\equal{1}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifexsh@bonus%
+ \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/bonus point}}%
+ \else%
+ \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/point}}%
+ \fi%
+ }{%
+ \ifexsh@bonus%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/bonus points}}%
+ \else%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points}}%
+ \fi%
+ }%
+ \fi%
+ }%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/pointsinfo}}}{}{%
+ \edef\exsh@points{\expandonce\exsh@points, \pgfkeysvalueof{/exsh/pointsinfo}}%
+ }%
+ }%
+ \ifthenelse{\equal{}{\exsh@points}}{%
+ \def\exsh@shortpoints{}%
+ }{%
+ \edef\exsh@shortpoints{ (\expandonce\exsh@points)}%
+ }%
+ \preto\exsh@points{\enskip\hfill\bgroup%
+ \pgfkeysvalueof{/exsh/points font}}%
+ \appto\exsh@points{\egroup}%
+ }%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/firstline}}}{%
+ \def\exsh@firstline{}%
+ }{%
+ \def\exsh@firstline{\pgfkeysvalueof{/exsh/firstline}}%
+ \preto\exsh@firstline{\quad\bgroup\normalfont\normalsize}%
+ \appto\exsh@firstline{\egroup}%
+ }%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/name}}}{%
+ \def\exsh@exname{}%
+ \def\exsh@shortexname{}%
+ }{%
+ \edef\exsh@exname{\space(\pgfkeysvalueof{/exsh/name})}%
+ \edef\exsh@shortexname{:\space\pgfkeysvalueof{/exsh/name}}%
+ }%
+ \refstepcounter{section}%
+ \edef\exsh@tmp{[\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}\exsh@shortexname\expandonce\exsh@shortpoints]}%
+ \ifbool{exsh@samplesolutions}{\ifbool{exsh@sample}{\exsh@hidefalse}{\exsh@hidetrue}}{\exsh@hidefalse}%
+ \ifbool{exsh@hide}{%
+ \def\exsh@skipwhat{exercise}\exsh@skipstuff%
+ }{%
+ \expandafter\exsh@startsection\exsh@tmp{\noindent%
+ \hbox to 0pt{\hss\pgfkeysvalueof{/exsh/exercisemark}}%
+ \pgfkeysvalueof{/exsh/strings/exercise}~\arabic{section}\exsh@exname\exsh@firstline\expandonce\exsh@points}%
+ \unskip\vskip\pgfkeysvalueof{/exsh/below exercise title skip}\relax
+ \@afterindentfalse
+ % automatic label for the first exercise in every included file
+ \ifthenelse{\equal{\jobname}{\currfilebase}}{}{%
+ \ifcsdef{exsh@autolabel@\currfilebase}{}{%
+ \csdef{exsh@autolabel@\currfilebase}{}%
+ \exsh@autolabel{ex:\currfilebase}}}%
+ % Use \leavevmode to ensure proper distances above environments that start
+ % 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
+ \ifexsh@beamer\clearpage\fi%%%% <<<<<BEAMER ONLY%%%%%%%%%%%%%%%%%
+}
+\newcommand{\exsh@label}[2]{#1{#2}\leavevmode\ignorespaces}
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\newcommand{\exsh@startsection}[2][]{%
+ \newpage
+% \begin{block}{}
+% \pgfkeysvalueof{/exsh/exercise title font}{#2}%
+% \end{block}
+ \ifbool{exsh@beameruseblocks}{%
+ \begingroup
+ \usebeamercolor{block title}
+ \setbeamercolor{block body}{bg=bg,fg=fg}
+ \block{}{\pgfkeysvalueof{/exsh/exercise title font}{#2}}%
+ \endblock
+ \endgroup
+ }{
+ \begin{beamercolorbox}[rounded=true,wd={\textwidth}]%
+ {block title}
+ \pgfkeysvalueof{/exsh/exercise title font}{#2}
+ \end{beamercolorbox}
+ }
+ \ifexsh@patchenumerate
+ \setbeamertemplate{enumerate items}{\insertenumlabel}
+ \renewcommand{\insertenumlabel}{
+ \ifnum\@enumdepth=1
+ \alph{enumi})
+ \else\ifnum\@enumdepth=2
+ \arabic{enumii}.
+ \else
+ \roman{enumiii}
+ \fi\fi
+ }
+ \fi
+}%
+\else%--------- NON-BEAMER: ---------------------------------------
+\newcommand{\exsh@startsection}[2][]{%
+ \@startsection{section}{1}{\z@}%
+ {\pgfkeysvalueof{/exsh/above exercise skip}}%
+ {1em}% afterskip corrected below
+ {\pgfkeysvalueof{/exsh/exercise title font}}%
+ [#1]{#2}%
+}%
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%includeoverride is not part of the public interface
+\exshset{includeoverride/.style={}}
+\def\includeexercise{%
+ \@ifstar\exsh@includeexercise@\exsh@includeexercise%
+}
+
+\newcommand{\exsh@includeexercise}[2][]{%
+ \ifbool{exsh@filenameasexercisename}{%
+ \exshset{includeoverride/.style={name={#2},#1}}%
+ }{%
+ \exshset{includeoverride/.style={#1}}%
+ }%
+ \input{\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}#2}
+ \exshset{includeoverride/.style={}}
+}
+
+\newcommand{\exsh@includeexercise@}[2][]{%
+ \ifbool{exsh@filenameasexercisename}{%
+ \exshset{includeoverride/.style={name={#2},#1}}%
+ }{%
+ \exshset{includeoverride/.style={#1}}%
+ }%
+ \begingroup
+ %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*}{}%
+ }
+ \input{\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}#2}
+ \endgroup
+ \exshset{includeoverride/.style={}}
+}
+
+
+\def\includeLexercise{%
+ \@ifstar\exsh@includeLexercise@\exsh@includeLexercise%
+}
+
+\ifluatex
+\newcommand{\exsh@includeLexercise}[2][]{%
+ \ifbool{exsh@filenameasexercisename}{%
+ \exshset{includeoverride/.style={name={#2},#1}}%
+ }{%
+ \exshset{includeoverride/.style={#1}}%
+ }%
+ \directlua{
+ local prefix =
+ "\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}"
+ exsh_cur_exercise=dofile(prefix .. "#2.lua")
+ exsh_texprintlines(exsh_cur_exercise)
+ }%
+ \exshset{includeoverride/.style={}}%
+}
+
+\newcommand{\exsh@includeLexercise@}[2][]{%
+ \ifbool{exsh@filenameasexercisename}{%
+ \exshset{includeoverride/.style={name={#2},#1}}%
+ }{%
+ \exshset{includeoverride/.style={#1}}%
+ }%
+ \begingroup
+ %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
+ \def\label##1{%
+ \PackageError{exercisesheets}{\string\label{##1}\space
+ inside \string\includeLexercise*}{}%
+ }
+ \directlua{
+ local prefix =
+ "\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}"
+ exsh_cur_exercise=dofile(prefix .. "#2.lua")
+ exsh_texprintlines(exsh_cur_exercise)
+ }%
+ \endgroup
+ \exshset{includeoverride/.style={}}
+}
+\else
+ \newcommand{\exsh@includeLexercise}[2][]{
+ \refstepcounter{section}
+ Lexercise needs Lua\LaTeX!
+ }
+ \let\exsh@includeLexercise@\exsh@includeLexercise
+\fi
+
+\AfterPackage*{varioref}{
+ \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.}
+ }
+ \AfterPackage*{enumitem}{
+ \setenumerate[1]{label=(\alph*)}
+ \setenumerate[2]{label=(\arabic*)}
+ \setenumerate[3]{label=\roman*.}
+ \setenumerate[4]{label=\Alph.}
+ }
+ \def\theHenumi{enumi.\arabic{part}.\arabic{section}.\arabic{enumi}}
+ \AtEndPreamble{%
+ \@ifpackageloaded{paralist}{}{%
+ \@ifpackageloaded{enumitem}{}{%
+ \apptocmd{\enumerate}{
+ \ifnum\@enumdepth=1%
+ \def\labelenumi{(\alph{enumi})}
+ \def\labelenumii{\arabic{enumii}.}
+ \def\labelenumiii{\roman{enumiii}.}
+ \fi
+ }{}{}%
+ }%
+ }%
+ }%
+\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}
+
+\long\def\exsh@savemaintask#1{%
+ \global\def\exsh@restatetaskmain{#1}%
+ #1%
+}
+
+\newenvironment{maintask}[1][]{%
+ \pgfkeys{exsh,#1}%
+ \pgfkeysvalueof{/exsh/main task font}%
+ \ifbool{exsh@savetasks}{\Collect@Body\exsh@savemaintask}{}%
+ \ignorespaces
+}{}
+
+\newenvironment{subtasks}[1][]{%
+ \pgfkeys{exsh,#1}%
+ \begin{\exsh@subtaskenv}
+ \ignorespaces
+}{
+ \end{\exsh@subtaskenv}%
+}
+
+\newcommand{\subtask}[2][]{%
+ \begingroup
+ \pgfkeys{exsh,#1}%
+ \csname\exsh@subtaskitm\endcsname%
+ {\pgfkeysvalueof{/exsh/subtask font} #2}%
+ \ifbool{exsh@savetasks}{%
+ \csgdef{exsh@restatetask\arabic{\exsh@subtaskctr}}{#2}%
+ }{}%
+ \endgroup
+}
+
+\newcommand{\restatetask}[1][main]{%
+ {\pgfkeysvalueof{/exsh/task restate font}%
+ \csname exsh@restatetask#1\endcsname}%
+}
+
+\newenvironment{hint}[1][]{%
+ \par
+ \pgfkeys{exsh,every hint,#1,hint font}%
+ \vskip\pgfkeysvalueof{/exsh/above hint skip}\relax\noindent
+ {\pgfkeysvalueof{/exsh/hint title font}\pgfkeysvalueof{/exsh/strings/hint}:}~\ignorespaces
+}{%
+ \par
+}
+\newenvironment{hint*}[1][]{%
+ \pgfkeys{exsh,every hint,#1,hint font}%
+ ({\pgfkeysvalueof{/exsh/hint title font}\pgfkeysvalueof{/exsh/strings/hint}:}\space%
+}{%
+ \unskip)%
+}
+
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+ \let\exsh@postsolutionclear\clearpage
+\else%--------- NON-BEAMER: ---------------------------------------
+ \let\exsh@postsolutionclear\par
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\providecommand{\solution}{}
+\renewenvironment{solution}[1][]{%
+ \pgfkeys{exsh,every solution,#1,solution font}%
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifbool{exsh@oralsolutions}{%
+ \let\next\exsh@startsolution
+ }{%
+ \let\next\exsh@skipsolution
+ }%
+ }{%
+ \ifbool{exsh@nonoralsolutions}{%
+ \let\next\exsh@startsolution
+ }{%
+ \let\next\exsh@skipsolution
+ }%
+ }%
+ \ifbool{exsh@forcesample}{%
+ \ifbool{exsh@samplesolutions}{%
+ \let\next\exsh@startsolution
+ }{}%
+ }{}%
+ \ifbool{exsh@beamersolution}{%
+ \let\next\exsh@skipsolution
+ }{}%
+ \next
+}{%
+ \ifbool{exsh@beamersolution}{}{%
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifbool{exsh@oralsolutions}{\exsh@postsolutionclear}{}%
+ }{%
+ \ifbool{exsh@nonoralsolutions}{\exsh@postsolutionclear}{}%
+ }%
+ }%
+}
+
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\def\exsh@solutiontitle#1{
+ \ifbool{exsh@beameruseblocks}{%
+ \begin{alertblock}{}%
+ \pgfkeysvalueof{/exsh/solution title font}%
+ \pgfkeysvalueof{/exsh/strings/solution} %
+ (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
+ \ifnum\@enumdepth>0\alph{subex}\fi)%
+ \end{alertblock}
+ }{
+ \begin{beamercolorbox}[rounded=true,wd={#1}]%
+ {block title alerted}
+ \pgfkeysvalueof{/exsh/solution title font}%
+ \pgfkeysvalueof{/exsh/strings/solution} %
+ (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
+ \ifnum\@enumdepth>0\alph{subex}\fi)%
+ \end{beamercolorbox}
+ }
+}
+\newcommand{\solutiontitle}[1][\linewidth]{
+ \ifhmode \linebreak\fi\exsh@solutiontitle{#1}
+}
+
+\newcommand{\deferredsolutiontitle}[1][\linewidth]{
+ \ifbool{exsh@defersolutiontitle}{%
+ \ifhmode \linebreak\fi\exsh@solutiontitle{#1}
+ }{}%
+}
+
+
+\long\def\exsh@processframes#1\newframe{%
+\ifstrequal{#1}{}{}{%
+\clearpage
+\begin{frame}[t]
+ \solutiontitle[\textwidth]
+ #1
+\end{frame}%
+\exsh@processframes%
+}%no whitespace here is crucial for end detecttion
+}
+
+
+\long\def\exsh@collectedframe#1{
+\exsh@processframes#1\newframe\newframe
+}
+
+\else%--------- NON-BEAMER: ---------------------------------------
+%this command is only usefule for exercisesheets-beamer to place
+%the deferred title within a new frame
+\newcommand{\solutiontitle}[1][]{}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\def\exsh@startsolution{%
+ \ifnum\@enumdepth=0
+ \clearpage
+ \fi
+% \usebeamercolor{block title alerted}
+% \setbeamercolor{block body}{bg=bg,fg=fg}
+% \block{}
+% \pgfkeysvalueof{/exsh/solution title font}%
+% \pgfkeysvalueof{/exsh/strings/solution} %
+% (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
+% \alph{subex})%
+% \endblock
+ \ifbool{exsh@framed}{\exsh@defersolutiontitletrue}{}
+ \ifbool{exsh@defersolutiontitle}{}{%
+ \ifhmode \linebreak\fi
+ \exsh@solutiontitle{\linewidth}
+ }%
+ \let\next\relax
+ \ifbool{exsh@framed}{%
+ \def\next{\Collect@Body\exsh@collectedframe}%
+ \ifbool{exsh@fragile}{%
+ \ifluatex%
+ \def\next{\exsh@start@lframed@}
+ \else
+ \PackageError{exercisesheets}{Fragile frames require
+ LuaLaTeX!}{}
+ \fi%
+ }{}%
+ }{}%
+ \next%
+}%
+\else%--------- NON-BEAMER: ---------------------------------------
+\def\exsh@startsolution{\@afterindentfalse
+ \vskip\pgfkeysvalueof{/exsh/above solution skip}\relax%
+ {\parindent \z@
+ \pgfkeysvalueof{/exsh/solution title font}%
+ \pgfkeysvalueof{/exsh/strings/solution}:\par}\nobreak%
+ \@afterheading
+}%
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\long\def\exsh@skipsolution#1{%
+ \ifstrequal{#1}{\end}{\exsh@endsolution}{\exsh@skipsolution}%
+}
+\def\exsh@endsolution#1{%
+ \ifstrequal{#1}{solution}{
+ \end{solution}
+ }{%
+ \ifstrequal{#1}{beamersolution}{
+ \end{beamersolution}
+ }{%
+ \exsh@skipsolution}%
+ }%
+}
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\newenvironment<>{beamersolution}[1][]{%
+ \pgfkeys{exsh,every solution,#1,solution font}%
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifbool{exsh@oralsolutions}{%
+ \let\next\exsh@startsolution
+ }{%
+ \let\next\exsh@skipsolution
+ }%
+ }{%
+ \ifbool{exsh@nonoralsolutions}{%
+ \let\next\exsh@startsolution
+ }{%
+ \let\next\exsh@skipsolution
+ }%
+ }%
+ \ifbool{exsh@forcesample}{%
+ \ifbool{exsh@samplesolutions}{%
+ \let\next\exsh@startsolution
+ }{}%
+ }{}%
+ \next
+}{%
+% \ifbool{exsh@framed}{\end{frame}}{}
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifbool{exsh@oralsolutions}{\clearpage}{}%
+ }{%
+ \ifbool{exsh@nonoralsolutions}{\clearpage}{}%
+ }%
+}
+\else%--------- NON-BEAMER: ---------------------------------------
+%the regular version of exercisesheets.sty skips all beamer solutions
+\newenvironment{beamersolution}[1][]{\exsh@skipsolution}{}%
+\fi
+%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newcommand{\points}[2][]{%
+ \ifthenelse{\equal{}{#2}}{}{\exshset{points=#2}}%
+ \bgroup%
+ \exshset{#1}%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/pointsinfo}}}{%
+ \def\exsh@tmp{}%
+ }{%
+ \def\exsh@tmp{, \pgfkeysvalueof{/exsh/pointsinfo}}%
+ }%
+ \ifthenelse{\equal{#2}{oral}}{%
+ \ifexsh@abbrev%
+ \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral abbrev}\exsh@tmp}%
+ \else%
+ \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral}\exsh@tmp}%
+ \fi%
+ }{%
+ \ifthenelse{\equal{#2}{}}{%
+ \exsh@subexpoints{\pgfkeysvalueof{/exsh/pointsinfo}}%
+ }{%
+ \ifexsh@abbrev%
+ \ifexsh@bonus%
+ \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/bonus points abbrev}\exsh@tmp}%
+ \else%
+ \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points abbrev}\exsh@tmp}%
+ \fi%
+ \else%
+ \ifthenelse{\equal{#2}{1}}{%
+ \ifexsh@bonus%
+ \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/bonus point}\exsh@tmp}%
+ \else%
+ \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/point}\exsh@tmp}%
+ \fi%
+ }{%
+ \ifexsh@bonus%
+ \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/bonus points}\exsh@tmp}%
+ \else%
+ \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points}\exsh@tmp}%
+ \fi%
+ }%
+ \fi%
+ \ifexsh@sumuppoints%
+ \ifexsh@bonus%
+ \addtocounter{exsh@ptsbonus@cur}{#2}
+ \else%
+ \addtocounter{exsh@pts@cur}{#2}
+ \fi%
+ \fi%
+ }%
+ }%
+ \egroup
+ \ignorespaces
+}
+
+\newenvironment{gradingguide}[1][]{%
+ \pgfkeys{exsh,#1,grading guide font}%
+ \ifbool{exsh@gradingguides}{%
+ \let\next\exsh@startguide
+ }{%
+ \let\next\exsh@skipguide
+ }%
+ \next
+}{}
+
+\def\exsh@startguide{\@afterindentfalse%
+ \par
+ {\parindent \z@
+ \pgfkeysvalueof{/exsh/strings/gradingguide}: }\nobreak%
+ \@afterheading
+}%
+
+\long\def\exsh@skipguide#1{%
+ \ifstrequal{#1}{\end}{\exsh@endguide}{\exsh@skipguide}%
+}
+\def\exsh@endguide#1{%
+ \ifstrequal{#1}{gradingguide}{\end{gradingguide}}{\exsh@skipguide}%
+}
+
+
+\ifluatex%
+ \ifdefined\luatextextdir
+ \def\exsh@putatend#1{%
+ \leavevmode\luatextextdir TRT\unskip{\luatextextdir TLT{\hfill~~#1}}\luatextextdir TLT}%
+ \else
+ \def\exsh@putatend#1{%
+ \leavevmode\textdir TRT\unskip{\textdir TLT{\hfill~~#1}}\textdir TLT}%
+ \fi
+\else%
+ \def\exsh@putatend#1{%
+ \TeXXeTstate=1%
+ \beginR\unskip{\beginL~~#1\endL}\hfill\beginL\TeXXeTstate=0}%
+\fi
+
+\def\exsh@leaveinplace#1{\unskip~{#1} }
+\def\exsh@insertFill#1{\unskip\nobreak\space\nobreak\hspace*{\fill}\allowbreak\hspace*{\fill}{#1}\unskip}
+
+\newcommand{\exsh@subexpoints}[1]{%
+ \ifexsh@inplace%
+ \exsh@leaveinplace{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}%
+ \else%
+ \ifexsh@pointsfloatright% can be used directly after \item etc.
+ \exsh@putatend{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}%
+ \else% original points macro with fill
+ \exsh@insertFill{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}%
+ \fi%
+ \fi%
+}
+
+\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}%
+}
+
+\newcommand{\iforalsolutions}[2]{%
+ \ifbool{exsh@oralsolutions}{#1}{#2}%
+}
+\newcommand{\ifnonoralsolutions}[2]{%
+ \ifbool{exsh@nonoralsolutions}{#1}{#2}%
+}
+\newcommand{\ifsamplesolutions}[2]{%
+ \ifbool{exsh@samplesolutions}{#1}{#2}%
+}
+\newcommand{\samplehide}[1]{%
+ \ifbool{exsh@samplesolutions}{}{#1}%
+}
+
+
+%%%%%%%%%%%%%%% BEGIN BEAMER-ONLY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifexsh@beamer
+\setbeamertemplate{headline}{%
+% \leavevmode%
+ \ifbool{exsh@beamerwithheadline}{%
+ \begin{beamercolorbox}[wd=\paperwidth,vmode]{frametitle}
+ \vspace{0.4em}
+ \leavevmode
+ \begingroup
+ \footnotesize%
+ \hspace*{2ex}{\pgfkeysvalueof{/exsh/subject font}%
+ \pgfkeysvalueof{/exsh/subject}} \hfill%
+ {\pgfkeysvalueof{/exsh/semester font}%
+ \pgfkeysvalueof{/exsh/semester}}\hspace{2ex}\hfil%
+ \vspace{1mm}\linebreak%
+ \hspace*{2ex}{\pgfkeysvalueof{/exsh/author font}\exsh@author}%
+ \hfill{\pgfkeysvalueof{/exsh/date font}%
+ \pgfkeysvalueof{/exsh/date}}%
+ \hspace{2ex}\hfil%\vspace{-1em}
+ \endgroup
+ \vspace{0.4em}
+ \end{beamercolorbox}%
+ \vspace*{3mm}
+ \vskip\pgfkeysvalueof{/exsh/below slide headline skip}\relax%
+ }{}%
+}
+\addtobeamertemplate{frametitle}{\vspace{-3mm}}{}
+
+\setbeamertemplate{footline}
+{%
+ \ifbool{exsh@beamerwithfootline}{%
+ \leavevmode%
+ \hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm]{frametitle}%
+ {\pgfkeysvalueof{/exsh/author font}\pgfkeysvalueof{/exsh/exauthor}}
+ \end{beamercolorbox}%
+ \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{author in head/foot}%
+ \usebeamerfont{author in head/foot}
+ \inserttitle
+ \hfill\insertpagenumber
+ \end{beamercolorbox}}%
+ \vskip0pt%
+ }{}%
+}
+\fi
+%%%%%%%%%%%%%%% END BEAMER-ONLY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\ifluatex
+ \let\exsh@dlua\directlua
+\else
+ \def\exsh@dlua#1{}
+\fi
+
+%change only some catcodes to
+\begingroup
+\catcode`!=0
+\catcode`\@=11
+\catcode`\_=12
+\catcode`\{=12 %set those to the same value (11/12) as below!
+\catcode`\}=12 %
+\catcode`<=1
+\catcode`>=2
+\catcode`\~=11
+\catcode`\\=11
+%% Expanded, when \catcode`\^^M=12 holds
+!global!long!def!exsh@start@Lexercise#1\end{Lexercise}< %
+ !exsh@dlua<exsh_cur_exercise=exercise({#1})> %
+ !endgroup!end<Lexercise>%
+>
+!global!long!def!exsh@start@skip@Lexercise#1\end{Lexercise}< %
+ !exsh@dlua<exsh_cur_exercise=exercise({#1})> %
+ !ifluatex!else!refstepcounter<section>!fi
+ !endgroup!endgroup%
+ !expandafter!exsh@skipstuff%
+ !exsh@dlua<exsh_texprintlines(exsh_cur_exercise)>%
+>
+!global!long!def!exsh@start@lframed#1\end{solution}< %
+ !exsh@dlua<exsh_cur_solution=fragileframed([[#1]])> %
+ !endgroup!end<solution>%
+ !exsh@dlua<exsh_texprintlines(exsh_cur_solution)>%
+>
+!endgroup
+
+\def\exsh@lua@catcodesBG{
+\begingroup
+\catcode`!=12
+\catcode`\$=12
+\catcode`\#=12
+\catcode`\_=12
+\catcode`\^=12
+\catcode`\&=12
+\catcode`\|=12
+\catcode`\{=12 %set those to the same value (11/12) as above!
+\catcode`\}=12 %
+\catcode`\~=12
+\catcode`\@=11
+\catcode`\%=12
+\catcode`\ =12
+\catcode9=12
+\catcode`\^^I=12
+\catcode`\^^J=12\catcode`\^^M=12\catcode`\\=11\endlinechar-1}
+
+\newenvironment{Lexercise}{%
+ \exsh@lua@catcodesBG\exsh@start@Lexercise%
+}{%
+ \ifluatex
+ \exsh@dlua{exsh_texprintlines(exsh_cur_exercise)}%
+ \else
+ \refstepcounter{section}
+ Lexercise needs Lua\LaTeX!
+ \fi
+}
+
+\def\exsh@skipstuff@Lexercise{\exsh@lua@catcodesBG\exsh@start@skip@Lexercise}%
+\def\exsh@start@lframed@{\exsh@lua@catcodesBG\exsh@start@lframed}
+
+\exsh@dlua{dofile("exsh_lexercise.lua")}
diff --git a/exercisesheets.tex b/exercisesheets.tex
new file mode 100644
index 0000000..914650b
--- /dev/null
+++ b/exercisesheets.tex
@@ -0,0 +1,835 @@
+%% exercisesheets.tex
+%% Copyright 2008-2022 Sebastian Kuhnert, Frank Fuhlbrück
+%
+% This work may be distributed and/or modified under the conditions
+% of the LaTeX Project Public License, either version 1.3c of this
+% license or (at your option) any later version. The latest version
+% of this license is in https://www.latex-project.org/lppl.txt and
+% version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Frank Fuhlbrück.
+%
+% This work consists of the files listed in README.
+
+\documentclass[DIV12,BCOR0mm]{scrartcl}
+
+\usepackage{arev}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage[activate]{microtype}
+\usepackage{csquotes}
+\usepackage{xspace}
+\usepackage{xcolor}
+\usepackage{calc}
+\usepackage{listings}
+\lstloadlanguages{TeX}
+\lstset{%
+ language=[LaTeX]TeX,
+ basicstyle=\ttfamily\color{blue!50!black},
+ keywordstyle=\bfseries,
+ morekeywords={subject},
+ identifierstyle=,
+ texcl,
+ commentstyle=\itshape,
+ showstringspaces=false,
+ breaklines,
+ breakatwhitespace,
+ columns=flexible,
+ escapeinside={(*}{*)},
+ mathescape=false,
+}
+
+\usepackage[pdfusetitle,colorlinks]{hyperref}
+
+\newcommand{\exsh}{\texttt{exercisesheets}\xspace}
+
+\newcommand{\param}[1]{$\langle${\normalfont\itshape #1\/}$\rangle$}
+\newcommand{\opt}[1]{\textcolor{green!50!black}{#1}}
+\newcommand{\option}[1]{{\normalfont\texttt{\color{blue!50!black}#1}}}
+
+\usepackage[english,iso]{isodate}
+\title{The \exsh Package}
+\author{Sebastian Kuhnert\and Frank Fuhlbrück}
+\date{Version 0.12, \printdateTeX{2022/09/02}}
+
+\begin{document}
+\maketitle
+
+The \exsh 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. Starting from Version 0.7, there was an alternative variant designed for use with the beamer class, which is integrated into the main package since version 0.11. Not all combinations of options have been tested with the beamer variant.
+
+
+\subsection*{Licence}
+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
+Frank Fuhlbrück
+\footnote{\href{mailto:frank@fuhlbrueck.net}{frank@fuhlbrueck.net}}.
+
+
+\section{Related Classes and Packages}
+
+\subsection{Packages with Similar Functionality}
+\begin{itemize}
+ \item The \texttt{exercise} package offers similar functionality, though the
+ concept is a bit different: That package provides explicit commands for
+ sub-exercises while \exsh relies on other means like the \texttt{enumerate}
+ environment for this. An advantage of the \texttt{exercise} package is that
+ answers can be delayed. On the other hand \exsh's environment based user
+ interface is a bit cleaner and you have to care less about package internals.
+\end{itemize}
+
+\subsection{Recommended Additional Packages}
+\begin{itemize}
+ \item The use of \texttt{hyperref} is encouraged. Please use the options
+ \texttt{pdfusetitle}, \texttt{plainpages=false} and \texttt{pdfpagelabels} for
+ optimal results.
+ \item If the \texttt{babel} package is loaded, the appropriate
+ \option{language=\param{lang}}-option is automatically derived and can be
+ omitted.
+ \item The use of \texttt{enumitem} or \texttt{paralist} is recommended. Top
+ level enumerating lists are then modified to have the form (a), (b), \dots{},
+ which is useful in exercise definitions.
+ \item If the \texttt{varioref} package is used, appropriate label formats are
+ installed for exercises and sub-exercises.
+ \item If the \texttt{xcolor} package is loaded, to-do markers generated with
+ \verb|\TODO| are printed in red.
+\end{itemize}
+
+\subsection{Packages Loaded by \exsh}
+\begin{itemize}
+ \item \texttt{etoolbox} (at least version
+ 1.7)
+ \item \texttt{scrlfile} (part of \KOMAScript{})
+ \item \texttt{pgfkeys} (part of PGF 2.0)
+ \item \texttt{ifthen}
+ \item \texttt{amsmath} (for \verb|\numberwithin|)
+ \item \texttt{iflualatex}
+ \item \texttt{refcount} (for \verb|\getrefnumber|)
+\end{itemize}
+
+
+\section{Basic Usage}
+
+\subsection{Package Loading}
+The beamer variant is integrated now and automatically activated
+if the current document class is beamer.
+
+\begin{lstlisting}
+\usepackage(*\opt{[\param{options}]}*){exercisesheets}
+\end{lstlisting}
+
+The following options are available:
+\begin{description}
+ \item[\option{only=\param{list of ranges}}] When given, only the mentioned
+ sheets will be included in the output. This is useful to speed up compilation
+ times for big documents. Some efforts are made that sheet and exercise
+ numbering remain consistent and references to exercises and enumerated lists
+ on skipped sheets still work as expected. References to other objects are
+ broken though (they currently point to the exercise or item containing them).
+ The \param{list of ranges} is a comma separated list of sheet numbers and
+ sheet ranges. If a comma is included in the range, it has to be protected with
+ a pair of braces. The special sheet \enquote{number} \texttt{last} stands for
+ the last sheet in the document (this may require an additional \LaTeX{} run).
+ Examples:
+ \begin{description}
+ \item[\option{only=3}] Only include the 3rd sheet of the document.
+ \item[\option{only=\{1,3,5,7\}}] Only include the sheets 1, 3, 5 and 7.
+ \item[\option{only=last}] Only include the last sheet of the document.
+ \item[\option{only=\{3-5,8-last\}}] Exclude the sheets 1, 2, 6 and 7.
+ \item[\option{only=\{-2,5-\}}] Exclude the sheets 3 and 4.
+ \end{description}
+ \item[\option{all}] Typeset all sheets (equivalent to \option{only=-}). This is
+ the default.
+ \item[\option{solutions\opt{=\param{true/false/oral/nonoral/sample oral/sample nonoral/sample all}}}] By default,
+ solutions (provided in the \texttt{solution} environment) are not included in
+ the output. By providing the option \option{solutions=true} (or just
+ \option{solutions}) this can be changed. Choosing \option{solutions=oral}
+ shows only solutions for exercises marked \option{oral} (useful for printouts
+ taken to class). Choosing \option{solutions=nonoral} shows only solutions for
+ exercises that are not marked \option{oral} (useful for correcting).
+ If you want to provided sample solutions for your students but only for some
+ of your exercises you can use the \texttt{sample} key to select those
+ exercises along with any options starting with sample here.
+ Note that non-sample exercises are skipped completely (not only their solutions) if you
+ choose an option starting with sample.
+ \item[\option{gradingguides\opt{=\param{true/false}}}]
+ Within \texttt{gradingguide} environments (usually used inside \texttt{solution}) you can
+ specify e.g. the amount of points to assign for certain solutions. This option
+ controls whether or not to include this guides in the output (e.g. solutions for
+ correcting contain them, but sample solutions for students don't).
+ \item[\option{solutionsby=\param{name/names}}] Use this to give the authors of the
+ solutions. They are credited at the beginning of each sheet, if the solutions
+ are included in the output.
+ \item[\option{language=\param{lang}}] Set the language of the sheet and
+ exercise heads to \param{lang}. If the \texttt{babel} package is loaded this
+ is not necessary, as the main document language will be automatically
+ detected. Currently \option{english}, \option{german} and \option{ngerman} are
+ supported. Other translations are welcome: Please contact the author.
+ \item[\option{pointsfloatright}] Use an alternative mechanism to place points for Sub-Exercises.
+ If this option is used, the points label for a Sub-Exercise is placed at the (right) end of the current line.
+ It is especially useful if used in a context like \texttt{$\backslash$item$\backslash$points$\{3\}$}.
+ This option exploits (and partially breaks) RTL-Support.
+ \item[\option{exercisespath}] Set the (relative) path of the
+ directory containing exercises to be included via
+ \verb|\includeexercise|.
+ \item[\option{patchenumerate}\opt{=\param{true/false}}] Sets
+ enumerate item labels for the first four levels, starting with
+ a), b) etc. for the top-level (sub-exercises). Depending on other
+ loaded packages (\verb|enumitem|, \verb|paralist|) the mechanism
+ slightly differs. This option is active by default.
+
+ \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}\opt{=\param{true/false}}]
+ 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->|. If you load \verb|exercisesheets| before them
+ use \verb|\exshset| afterwards.
+ 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>##2{##2}
+ \def\uncover<##1>##2{##2}
+ \def\visible<##1>##2{##2}
+ \def\invisible<##1>##2{##2}
+ \long\def\alt<##1>##2##3{##2}
+ \long\def\temporal<##1>##2##3##4{##3}
+ \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}
+
+\item[\option{filenameasexercisename}\opt{=\param{true/false}}]
+This option (set to false by default) causes
+\verb|\includeexercise| to
+set the name of an exercise as the filename (without extension).
+This has two purposes: If you have nice file names you can
+automatically name the exercise. On the other hand this is helpful
+during exercise sheet composition because it shows the name of
+the corresponding file in the compiled file.
+\end{description}
+
+\subsection{Supplying Meta-Data}
+
+The following commands are enhanced (or provided) to set the options controlling
+the sheet headers (see Section~\ref{sec:sheet}):
+\begin{lstlisting}
+\subject{(*\param{subject}*)}
+\author{(*\param{author}*)}
+\date{(*\param{semester}*)}
+\end{lstlisting}
+
+If one of these commands is omitted (and the corresponding option is not used
+either), a warning is issued.
+
+Please do not include a \lstinline|\title| in your document, as \exsh will
+automatically generate an appropriate one (this may require an additional
+\LaTeX{} run).
+
+All this information is included in the PDF meta-data if the \texttt{hyperref}
+package is loaded with the option \texttt{pdfusetitle}.
+
+There is also a related option:
+\begin{description}
+ \item[\option{exauthor=\param{list of names}}] If you want to use the
+ \lstinline|\author| macro for the general author of a course but
+ there are different authors for individual exercises or all
+ exercises in general, you can set this key. Currently only
+ exercisesheets-baemer uses this for the footline, while
+ \option{author} is used for the headline.
+\end{description}
+
+\subsection{Defining Exercise Sheets}
+\label{sec:sheet}
+\begin{lstlisting}
+\begin{sheet}(*\opt{[\param{options}]}*)
+ (*\param{sheet contents}*)
+\end{sheet}
+\end{lstlisting}
+
+Insert a sheet into the document. This environment can be repeated to combine
+several sheets in a single \LaTeX{} file. For each sheet, a new page is started
+and an appropriate header is generated. The \param{sheet contents} can be
+anything but will usually consist of several \texttt{exercise} environments (see
+Section~\ref{sec:exercises-solutions}).
+
+The following \param{options} are supported:
+\begin{description}
+ \item[\option{date=\param{date}}] Set the date the sheet was/will be issued. This
+ information is included in the sheet header. By default, this information is
+ omitted. See also the \option{semester} option.
+ \item[\option{note=\param{note}}] Include \param{note} in the sheet header.
+ Useful to inform students when the sheet is due. If you want a note consisting
+ of more than one line split at a particular position, use
+ \verb|\protect\linebreak|.
+ \item[\option{title=\param{title}}]
+ Directly set the sheet title. When this option is used, different
+ page numbering conventions are used. This is useful to
+ typeset exams (combined with the next option).
+ \item[\option{number within sheet\opt{=\param{true/false}}}]
+ Deviate from the usual numbering theme and
+ restart from one for exercises on the sheet. The previous
+ counter value is restored after the sheet, so you can insert
+ a special sheet.
+ \item[\option{author=\param{author}}] Set the author included in the sheet
+ head. By default, the value passed to \verb|\author| is used.
+ \item[\option{exauthor=\param{exauthor}}] Only used by the beamer
+ variant, see above.
+ \item[\option{subject=\param{subject}}] Set the subject included in the sheet
+ head. By default, the value passed to \verb|\subject| is used.
+ \item[\option{semester=\param{semester}}] Set the semester included in the
+ sheet head. By default, the value passed to \verb|\date| is used.
+ \item[\option{beamerwithheadline\opt{=\param{true/false}}}] Controls whether a headline with author, subject etc. is shown on beamer slides, similar to the regular sheets. This options is off by default as headlines (and footers) take a considerable amount
+ off space.
+ \item[\option{beamerwithfootline\opt{=\param{true/false}}}]
+ The same for the footer.
+ \item[\option{beameruseblocks\opt{=\param{true/false}}}]
+ Controls whether the exercise title is shown inside a
+ beamer block (\param{true}) or a simple colorbox
+ (\param{false}, the default). Depending on your style a
+ block might look fancier, but it usually consume more space.
+\end{description}
+
+
+\subsection{Defining Exercises and Solutions}
+\label{sec:exercises-solutions}
+\begin{lstlisting}
+\begin{exercise}(*\opt{[\param{options}]}*)
+ (*\param{exercise text}*)
+ \begin{solution}(*\opt{[\param{solution options}]}*)
+ (*\param{solution text}*)
+ \end{solution}
+ \begin{beamersolution}(*\opt{[\param{solution options}]}*)
+ (*\param{solution text}*)
+ \end{beamersolution}
+\end{exercise}
+\end{lstlisting}
+
+This inserts an exercise into the current document. All
+\option{beamersolution}s are ignored, if the
+\exsh package with any class but beamer, but using beamer
+\exsh also processes
+normal solutions by default (set option \option{beamersolution}
+to turn this off).
+
+The following options are
+supported:
+\begin{description}
+ \item[\option{name=\param{text}}] Use \param{text} as the name of the exercise.
+ 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{savetasks\opt{=\param{true/false}}}] Saves the main task and each sub task
+ for later use with \verb|\restatestask[|%
+ \param{which}], where \param{which} is either \verb|main|
+ (default) or the number of a sub task.
+ \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. Points can be summed up also during a single pass
+ by using the Lua interface.
+ \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
+ information to be displayed after the points.
+ \item[\option{optional}] Shortcut for \option{pointsinfo=optional} with
+ automatic translation and abbreviation (if requested).
+ \item[\option{bonus}] Change \enquote{points} to \enquote{bonus points} (with
+ automatic translation and abbreviation).
+ \item[\option{abbrev}] Use abbreviated labels.
+ \item[\option{exercisemark=\param{symbol}}] Mark the exercise
+ with \param{symbol} in the left margin.
+ \item[\option{difficult}] Shortcut for \option{exercisemark=*}.
+ \item[\option{solutions\opt{=\param{true/false/oral/nonoral/...}}}] Use this to override the
+ document (or sheet) default.
+ \item[\option{sample}] Include this exercise (and its solution) in while compiling
+ sample solutions.
+ \item[\option{beamersolution}] For beamer variant only. If this option
+ is set all normal solutions will not be included and only
+ \option{beamersolution}s are typeset.
+ \item[\option{framed}] For beamer variant 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
+can be multiple solution environments within a single exercise environment; this
+is useful if the exercise consists of several sub-exercises. Sub-exercises can
+simply be defined with an \texttt{enumerate} or \texttt{compactenum}
+environment.
+
+\section{Utilities}
+
+\subsection{Loading Excercises From Files}
+\begin{lstlisting}
+\includeexercise(*\param{file name}*)
+\includeexercise*(*\param{file name}*)
+\end{lstlisting}
+
+Both load the exercise from exercisespath/\param{file name}. Note
+that the exercise environment must be contained in the file. The
+starred version is helpful for faster skipping of unused exercises.
+In this case, the file is not opened to search for labels. Whenever
+the exercise is not skipped and you use the starred version and also
+use labels within the exercise file, \exsh outputs an error. This is
+done to ensure that references are not overlooked when the exercise
+is actually skipped later.
+
+\subsection{Including Hints}
+
+\begin{lstlisting}
+\begin{hint}(*\opt{[\param{options}]}*)
+ (*\param{hint text}*)
+\end{hint}
+\end{lstlisting}
+
+\begin{lstlisting}
+\begin{hint*}(*\opt{[\param{options}]}*)
+ (*\param{hint text}*)
+\end{hint*}
+\end{lstlisting}
+
+These environments include hints in the exercise definition. The first form
+starts a new paragraph, the second one puts the hint in parenthesis.
+
+\subsection{TODO Markers}
+
+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. 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[what needs to be done]
+\end{lstlisting}
+
+\subsection{Annotating Points for Sub-Exercises}
+\begin{lstlisting}
+\begin{exercise}[points=sum]%sum produces 4+6
+ \begin{enumerate}
+ \item Part 1 \points{oral}
+ \item Part 2 \points[optional]{oral}
+ \item Part 3 \points{4}
+ \item Part 4 \points[bonus]{6}
+ \end{enumerate}
+ Sub-Exercises within continuous text can be annotated like this \points[inplace]{3} without adding space.
+\end{exercise}
+\end{lstlisting}
+
+\subsection{Explicitly Stating Tasks}
+In principle, \exsh aims to be very lightweight and there is not
+much mandatory structure inside exercises. Furthermore, the
+\verb|enumi| counter is used for sub-exercise. There are, however,
+situations where we want more explicit structure, for instance to
+have special font for the main task or the subtasks or to reuse
+some of the tasks later. This is especially handy if using the
+beamer variant where the origial task and a part of the solution might be on different slides. In the future it might be possible to
+use other counters then \verb|enumi|, which is also only possible
+if sub-exercises are not simply \verb|\item|s in
+\verb|enumerate|.
+
+
+\begin{lstlisting}
+\begin{exercise}[points=sum]%sum produces 4+6
+ \begin{maintask}
+ This is the main task.
+ \end{maintask}
+ \begin{subtasks}
+ \subtask{first}
+ \subtask{second}
+ \end{subtasks}
+ \begin{solution}[framed]
+ We want to show: \restatestask %This is the main task.
+ \newframe
+ Out first step is to show: \restatetask[1] %first
+ \end{solution}
+\end{exercise}
+\end{lstlisting}
+
+\subsection{Labels and References within an Exercise}
+While the global reference labels set via varioref (if loaded)
+are nice for references to subexercises far away, always mentioning
+the exercise number seems superfluous. Furthermore, for usage in indices etc. you might want to use the arabic representation instead. This is what the commands \verb|\subexnref| and
+\verb|\subexlref| are designed for. However, both of them still
+require an ordinary label, which is not allowed in
+exercises loaded with \verb|\loadexercise*|.
+For this purpose \verb|\inexlabel| can be used which is just a
+normal label that is not redefined to produce an error.
+Furthermore, we define a counter \verb|subex| (which is
+currently just an alias for enumi, but this might change). You can
+use this counter (alias) with common commands like
+\verb|\arabic| or \verb|\alph|.
+
+\begin{lstlisting}
+\begin{exercise}
+ \begin{enumerate}
+ \item \inexlabel{subex:xisseven} Let $x_{\thesubex}=7$.
+ \item Compute $x_{\subexnref{subex:xisseven}}+3$.
+ \begin{solution}
+ From \subexlref{subex:xisseven} %(a)
+ we know that $x_{\subexnref{subex:xisseven}}$ is $7$ and
+ thus the sum is $10$.
+ \end{solution}
+ \end{enumerate}
+\end{exercise}
+\end{lstlisting}
+
+
+
+\section{Advanced Usage}
+
+\subsection{Setting Options}
+
+Options can be given at different places.
+\begin{enumerate}
+ \item As local options to one of the environments.
+ \item As package options: This is convenient for global options but suffers
+ from shortcomings in way \LaTeX{} processes options: Macros are expanded and
+ spaces are stripped.
+ \item By the independent \verb|\exshset| command. This is especially useful in
+ the preamble to set options that would be garbled by the \LaTeX{} option
+ handling routine. It also allows to change an option for the rest of the
+ current scope.
+\end{enumerate}
+
+Example: Change the solution authors of the following sheets:
+\begin{lstlisting}
+(*\param{some sheets}*)
+\exshset{solutionsby=(*\param{other authors}*)}
+(*\param{more sheets}*)
+\end{lstlisting}
+
+\subsection{Changing Strings}
+
+For some languages, predefined sets of strings are provided and automatically
+activated. If your language is not supported or if you want to change (some of)
+the used strings, you can do so with the following options:
+\begin{description}
+ \item[\option{strings/sheet=\param{string}}]
+ \item[\option{strings/sheets=\param{string}}]
+ \item[\option{strings/solutions=\param{string}}]
+ \item[\option{strings/solutionsby=\param{string}}]
+ \item[\option{strings/exercise=\param{string}}]
+ \item[\option{strings/solution=\param{string}}]
+ \item[\option{strings/hint=\param{string}}]
+ \item[\option{strings/oral=\param{string}}]
+ \item[\option{strings/oral abbrev=\param{string}}]
+ \item[\option{strings/point=\param{string}}]
+ \item[\option{strings/points=\param{string}}]
+ \item[\option{strings/points abbrev=\param{string}}]
+ \item[\option{strings/bonus point=\param{string}}]
+ \item[\option{strings/bonus points=\param{string}}]
+ \item[\option{strings/bonus points abbrev=\param{string}}]
+ \item[\option{strings/optional=\param{string}}]
+ \item[\option{strings/optional abbrev=\param{string}}]
+\end{description}
+
+Example: Give an introduction that should only be included in the version with
+solutions:
+
+\begin{lstlisting}
+\begin{solution}[strings/solution=Introduction]
+ (*\param{introduction text}*)
+\end{solution}
+\end{lstlisting}
+
+
+\subsection{Changing Fonts}
+
+The package \exsh comes with its own way to change the used fonts. Each font can
+be changed in the following way:
+\begin{lstlisting}
+\exshset{(*\param{font element}=\param{font specification}*)}
+\end{lstlisting}
+The available \param{font element}s are listed below together with their default
+values:
+\begin{description}
+ \item[\option{sheet header font}] The basic font for subject, author, semester,
+ date, note and solution authors in the sheet headers.\\
+ Default: \verb|\normalfont\normalsize|
+ \item[\option{subject font}] The font for the subject in the sheet header.\\
+ Default: \verb|\scshape|
+ \item[\option{author font}] The font for the author in the sheet header.\\
+ Default: \verb|\scshape|
+ \item[\option{semester font}] The font for the semester in the sheet header.\\
+ Default: empty, i.\,e.\ no change.
+ \item[\option{date font}] The font for the date in the sheet header.\\
+ Default: empty, i.\,e.\ no change.
+ \item[\option{solutionsby font}] The font for the information who has produced
+ the solutions provided below the sheet title.\\
+ Default: \verb|\itshape|
+ \item[\option{sheet note font}] The font for the note provided below the sheet
+ title.\\
+ Default: \verb|\itshape\bfseries|
+ \item[\option{sheet title font}] The font for the sheet title itself.\\
+ Default: \verb|\Large\bfseries|
+ \item[\option{exercise title font}] The font for the exercise title.\\
+ Default: \verb|\bfseries|
+ \item[\option{points font}] The font for the number of points in the exercise
+ head (relative to the exercise title) and for \verb|\points|.\\
+ Default: \verb|\itshape|
+ \item[\option{main task font}] The font for the
+ \verb|maintask| environment.\\
+ Default: empty, i.\,e.\ no change.
+ \item[\option{subtask font}] The font for each
+ \verb|\subtask|.\\
+ Default: empty, i.\,e.\ no change.
+ \item[\option{task restate font}] The font used for
+ \verb|\restatestask|.\\
+ Default: \verb|\itshape|
+ \item[\option{hint font}] The font for hints. \\
+ Default: empty, i.\,e.\ no change.
+ \item[\option{hint title font}] The font for the string \enquote{Hint:}.\\
+ Default: \verb|\itshape|
+ \item[\option{solution font}] The font for solutions.\\
+ Default: empty, i.\,e.\ no change.
+ \item[\option{solution title font}] The font for the string
+ \enquote{Solution:}\\
+ Default: \verb|\bfseries|
+ \item[\option{grading guide font}] The font for grading guides.\\
+ Default: \verb|\itshape|
+ \item[\option{todo marker font}] The font for the string \enquote{TODO}.\\
+ Default: \verb|\ifdef{\color}{\color{red}}{}\bfseries|
+\end{description}
+
+\subsection{Controlling the Spacing and Page Handling}
+
+The following options allow fine-tuning of the spacing:
+\begin{description}
+ \item[\option{below slide headline skip=\param{dimen}}] The distance between
+ haedline (if present) and slide content. Only used by beamer
+ variant, ignored elsewhere.\\
+ Default: \texttt{0mm}
+ \item[\option{above sheet title skip=\param{dimen}}] The distance between
+ author/date and sheet title.\\
+ Default: \texttt{4ex}
+ \item[\option{above sheet note skip=\param{dimen}}] The distance above the
+ sheet note.\\
+ Default: \texttt{.7ex}
+ \item[\option{above solutionsby skip=\param{dimen}}] The distance above the
+ solution author.\\
+ Default: \texttt{1ex}
+ \item[\option{below sheet header skip=\param{dimen}}] The distance below the
+ sheet header.\\
+ Default: \texttt{4ex plus 1ex minus .5ex}
+ \item[\option{above exercise skip=\param{dimen}}] The distance above
+ exercises.\\
+ Default: \texttt{3ex plus 1ex minus .5ex}
+ \item[\option{below exercise title skip=\param{dimen}}] The distance below
+ exercise titles.\\
+ Default: \texttt{\textbackslash parskip}
+ \item[\option{above solution skip=\param{dimen}}] The distance above
+ solutions.\\
+ Default: \texttt{1ex}
+ \item[\option{above hint skip=\param{dimen}}] The distance above hints.\\
+ Default: \texttt{1ex}
+\end{description}
+
+The following two options control the page handling at the beginning and
+at the end of each sheet:
+\begin{description}
+ \item[\option{sheet start page action=\param{macro}}] Executed at the beginning
+ of each sheet.\\
+ Default: \texttt{\string\clearpage}
+ \item[\option{sheet end page action=\param{macro}}] Executed at the end
+ of each sheet.\\
+ Default: \texttt{\string\clearpage}
+\end{description}
+
+\subsection{Special Code for Solutions}
+\begin{lstlisting}
+\ifsolutions{(*\param{if true}*)}{(*\param{if false}*)}
+\iforalsolutions{(*\param{if true}*)}{(*\param{if false}*)}
+\ifnonoralsolutions{(*\param{if true}*)}{(*\param{if false}*)}
+\end{lstlisting}
+
+There are also special options for conditionals to be used in the arguments of
+the environments defined by this package:
+\begin{description}
+ \item[\option{ifsolutions=\{\param{options if true}\}\{\param{options if
+ false}\}}] Execute \param{options if true} if solutions are included in
+ the current document, \param{options if false} otherwise.
+ \item[\option{iforalsolutions=\{\param{options if true}\}\{\param{options if
+ false}\}}] Execute \param{options if true} if solutions for oral exercises
+ are included in the current document, \param{options if false} otherwise.
+ \item[\option{ifnonoralsolutions=\{\param{options if true}\}\{\param{options if
+ 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:
+\begin{lstlisting}
+\ifsolutions{}{\renewcommand{\points}[2][]{}}
+\end{lstlisting}
+
+Example 2: Modify the sheet header spacing in the non-solution version:
+\begin{lstlisting}
+\begin{sheet}[ifsolutions={}{above title skip=2ex}]% usually 4ex
+ \dots
+\end{sheet}
+\end{lstlisting}
+
+\subsection{Using Hooks}
+There are several hooks used by \exsh:
+\begin{description}
+ \item[\option{every sheet}] This is used at the beginning of every sheet.
+ \item[\option{every exercise}] This is used at the beginning of every exercise.
+ \item[\option{every solution}] This is used at the beginning of every solution.
+ \item[\option{every hint}] This is used at the beginning of every hint.
+\end{description}
+
+Hooks can be used to influence the behaviour of the respective environments.
+Users of \texttt{tikz} should be familiar with the concept.
+
+\subsection{Control Skipping of Custom Macros in Skipped Exercises}
+\begin{description}
+ \item[\option{custom skip macro=\param{macro}}]
+\end{description}
+
+If an exercise is not printed, some macros like \texttt{\string\label{}}
+are processed nevertheless. However, if you define your own macro
+using one of these, then this macro will be completely ignored
+if the exercise containing it is skipped. This option allows to
+define a custom handler for your macros. The most common use
+checks for your custom macros with
+nested \texttt{\string\ifstrequal}s and then either
+executes a custom skipper, replaces your macro with
+the standard version or uses \texttt{\string\expandafter} to
+deliver the expanded version of your macro to
+\texttt{\string\exshskipcontinue}.
+
+Example:
+\begin{lstlisting}
+\def\mylabel#1{...}
+\def\myitem{...}
+\def\myitemtwo{...}
+\def\skipmylabel#1{...\exshskipcontinue}
+\long\def\customskip#1{
+ \ifstrequal{#1}{\mylabel}
+ {\skipmylabel}
+ {\ifstrequal{#1}{\myitem}
+ {\exshskipcontinue\item}
+ {\ifstrequal{#1}{\myitemtwo}
+ {\expandafter\exshskipcontinue\myitemtwo}
+ {\exshskipcontinue}
+ }
+ }
+}
+\exshset{custom skip macro={\customskip}}
+\end{lstlisting}
+
+\section{The Lua Interface}
+\label{sec:lua}
+
+Since version 0.11 there is a Lua interface for the exercise
+environment. This interface will offer roughly the same features.
+Its main purpose will be allowing to reorder sub-exercises more
+easily and to offer more dynamic options for the display of
+solutions (one combined solution or single after each sub-%
+exercise). %TODO finish
+
+\begin{lstlisting}
+\begin{Lexercise}
+ --use [[]] if you need \ or escape it in "": "\\"
+ firstline = [[Assume $\pi=4$.]],
+ points=10,
+ name="Pragmatic",
+ options=[[main task font={\itshape}]],
+ task = [[
+ This is the main task specified via the Lua
+ interface.
+ ]],
+ solution=[[
+ This is a solution for the main task.
+ ]],
+\end{Lexercise}
+\end{lstlisting}
+
+\section{Usage Tips}
+\label{sec:usage-tips}
+
+\subsection{Seperate Solution File}
+\label{sec:seper-solut-file}
+
+If you do not want to temporarily comment out the \option{solutions} option in
+your main file, say \texttt{exercises.tex}, you can create an additional file
+\texttt{solutions.tex} with the following contents:
+\begin{lstlisting}
+\PassOptionsToPackage{solutions}{exercisesheets}
+\input{exercises.tex}
+\end{lstlisting}
+If you leave out the \option{solutions} option in you main file, running
+\texttt{pdflatex exercises.tex} will create \texttt{exercises.pdf} without
+solutions and \texttt{pdflatex solutions.tex} will create \texttt{solutions.pdf}
+with solutions.
+
+This also works well in combination with a make file that generates
+\texttt{solutions.tex}.
+
+
+\section{Changelog}
+\label{sec:changelog}
+
+\begin{itemize}
+ \item[v. 0.11:] 2022-02-11
+ \begin{itemize}
+ \item Local references and the subex counter
+ \item Lua interface (not documented yet, see example and example file)
+ \item Framed solutions can now be fragile, however this
+ also require Lua\LaTeX (but not using the Lua Interface).
+ \item beamer version is now included (no separate package)
+ \item some bug fixes
+ \end{itemize}
+\end{itemize}
+
+
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
+
+%%% Local IspellDict: british
diff --git a/exsh_lexercise.lua b/exsh_lexercise.lua
new file mode 100644
index 0000000..85a298b
--- /dev/null
+++ b/exsh_lexercise.lua
@@ -0,0 +1,136 @@
+exsh_texprintlines = function(s)
+ for line in s:gmatch("[^\n]*") do
+ tex.print(line)
+ end
+end
+
+
+solution = function(sol)
+ if type(sol) ~= "string" then
+ local solt = sol
+ sol = "["
+ if solt.idea then
+ sol = sol .. "idea,"
+ end
+ if solt.name then
+ sol = sol .. "strings/solution={"..solt.name.."},"
+ end
+ sol = sol .. "] " .. (solt.text or "")
+ end
+ return [[\begin{solution}]]..sol..[[\end{solution}]]
+end
+
+subexercise = function(se)
+ local pts,p,bp = ""
+ local sols = ""
+ if type(se) ~= "string" then
+ local set = se
+ local po = ""
+ if set.pointoptions then
+ po = po .. set.pointoptions
+ end
+ p,bp = set.points,set.bonuspoints
+ if p and bp then
+ pts = [[\points[]] .. po .. "]{" .. set.points .. "+" ..
+ set.bonuspoints .. "}"
+ elseif bp then
+ pts = [[\points[bonus,]] .. po .. "]{" .. set.bonuspoints .. "}"
+ elseif p then
+ pts = [[\points[]] .. po .. "]{" .. set.points .. "}"
+ end
+
+ if set.solution then
+ sols = sols .. solution(set.solution)
+ end
+ if set.altsolutions then
+ for _,sol in ipairs(set.altsolutions) do
+ sols = sols .. solution(sol)
+ end
+ end
+
+ se = "["
+ if set.options then
+ se = se .. set.options
+ end
+ se = se .. "]{" .. (set.task or "") .. "}"
+ else
+ se = "{" .. se .. "}"
+ end
+ return [[\subtask]]..se .. pts .. sols, p, bp
+end
+
+exercise = function(ex)
+ local subex = ""
+ local pts,bpts = 0,0
+ if ex.subexercises then
+ subex = [[\begin{subtasks}]]
+ for _,se in ipairs(ex.subexercises) do
+ local s,p,bp = subexercise(se)
+ subex = subex .. s
+ pts = pts + (p or 0)
+ bpts = bpts + (bp or 0)
+ end
+ subex = subex .. [[\end{subtasks}]]
+ end
+ if ex.points and ex.points == "sum" then
+ if pts > 0 and bpts > 0 then
+ pts = pts .. "+" .. bpts
+ elseif bpts > 0 then --and pts = 0
+ pts = bpts
+ ex.options = (ex.options or "") .. ",bonus"
+ --else bpts = 0 thus pts is all points
+ end
+ else
+ pts = ex.points
+ end
+
+ local ece = [[\begin{exercise}[]]
+ if ex.firstline then
+ ece = ece .. [[firstline={]] .. ex.firstline .. [[},]]
+ end
+ if pts then
+ ece = ece .. [[points={]] .. pts .. [[},]]
+ end
+ if ex.name then
+ ece = ece .. [[name={]] .. ex.name .. [[},]]
+ end
+ if ex.options then
+ ece = ece .. ex.options .. ","
+ end
+ ece = ece .. "]{}"
+ if ex.task then
+ ece = ece .. [[\begin{maintask}]] .. ex.task
+ .. [[\end{maintask}]]
+ end
+ if ex.solution then
+ ece = ece .. solution(ex.solution)
+ end
+ if ex.altsolutions then
+ for _,sol in ipairs(ex.altsolutions) do
+ ece = ece .. solution(sol)
+ end
+ end
+
+ ece = ece .. subex
+
+ ece = ece .. "\n" .. [[\end{exercise}]]
+ return ece
+end
+
+fragileframed = function(s)
+ local frames,p,pn,n,i = {},1,1,#s,0
+ pn = s:find([[\newframe]],p) or n+1
+ while p < n do
+ i = i+1
+ frames[i] = [[
+ \begin{frame}[t,fragile]
+ \solutiontitle[\textwidth]
+ ]] .. s:sub(p,pn-1) .. [[
+ \end{frame}
+ ]]
+ p = pn + 9
+ pn = s:find([[\newframe]],p) or n+1
+ end
+ return table.concat(frames,"")
+end
+