From ba876caba67cdc6502b0daa6d5b8ca247be6dbe9 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 24 Apr 2024 20:20:13 +0000 Subject: exercisesheets (24apr24) git-svn-id: svn://tug.org/texlive/trunk@71063 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/exercisesheets/README | 17 + .../examples/exercises/exshexample-ex1.tex | 9 + .../examples/exercises/exshexample-ex2.lua | 7 + .../examples/exshexample-embedded.tex | 116 ++ .../latex/exercisesheets/examples/exshexample.tex | 286 +++ .../latex/exercisesheets/exercisesheets-doc.pdf | Bin 0 -> 128498 bytes .../latex/exercisesheets/exercisesheets-doc.tex | 1086 +++++++++++ .../tex/latex/exercisesheets/exercisesheets.sty | 1961 ++++++++++++++++++++ Master/tlpkg/bin/tlpkg-ctan-check | 2 +- Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 + Master/tlpkg/tlpsrc/exercisesheets.tlpsrc | 0 11 files changed, 3484 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/README create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex1.tex create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex2.lua create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample-embedded.tex create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample.tex create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.pdf create mode 100644 Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.tex create mode 100644 Master/texmf-dist/tex/latex/exercisesheets/exercisesheets.sty create mode 100644 Master/tlpkg/tlpsrc/exercisesheets.tlpsrc diff --git a/Master/texmf-dist/doc/latex/exercisesheets/README b/Master/texmf-dist/doc/latex/exercisesheets/README new file mode 100644 index 00000000000..e9b2e492420 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercisesheets/README @@ -0,0 +1,17 @@ +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-2024 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-doc.tex Documentation source +exsh_lexercise.lua Helper file for internal lua code +README This file +examples Folder with example tex files +examples/exercises Example exercise used by example tex files diff --git a/Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex1.tex b/Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex1.tex new file mode 100644 index 00000000000..395aef31564 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex1.tex @@ -0,0 +1,9 @@ +\begin{exercise} + Include an exercise from an external file. + \begin{solution}[framed] + I just did this. + \pause + And this, too. + \end{solution} +\end{exercise} + diff --git a/Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex2.lua b/Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex2.lua new file mode 100644 index 00000000000..23012696cd8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercisesheets/examples/exercises/exshexample-ex2.lua @@ -0,0 +1,7 @@ +return exercise { + task = [[Include an exercise via the Lua interface.]], + solution=[[ + I think this worked. + ]], +} + diff --git a/Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample-embedded.tex b/Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample-embedded.tex new file mode 100644 index 00000000000..d9cf5576471 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample-embedded.tex @@ -0,0 +1,116 @@ +\documentclass[aspectratio=169]{beamer} +\usetheme{Berlin} +\usefonttheme{professionalfonts} +\useoutertheme{infolines} +\useinnertheme{rounded} +\setbeamertemplate{itemize items}[circle] +\setbeamertemplate{enumerate items}[circle] +\setbeamertemplate{sections/subsections in toc}[circle] +\setbeamercolor{item projected}{bg=black} +\setbeamercolor{item}{fg=black} +\setbeamertemplate{navigation symbols}{} + +\setbeamertemplate{footline}[frame number] + +\setbeamercolor{block title}{bg=black} +\setbeamercolor{section in toc}{fg=red,bg=white} + +\AtBeginSection[]{ +\begin{frame} +\begin{block}{Overview} +\tableofcontents[sectionstyle=show/shaded,subsectionstyle=hide/hide/hide] +\end{block} +\end{frame} +} + +\AtBeginSubsection[]{ +\begin{frame}[allowframebreaks] +\begin{block}{Overview} +\tableofcontents[sectionstyle=show/hide,subsectionstyle=show/shaded/hide] +\end{block} +\end{frame} +} + + +\author{Example Author} +\title{Embedding Exercises} +\subtitle{a never-ending journey} +\makeatletter +\date{compilation date: \the\year-\two@digits{\the\month}-\two@digits{\the\day}} +\makeatother + + + +\newenvironment<>{stlist}[1][]{% + \setbeamertemplate{enumerate items}{\alph{enumi})} + \setbeamertemplate{enumerate subitem}{\arabic{enumii}.} + \setbeamertemplate{enumerate subsubitem}{\arabic{enumii}.} + \begin{enumerate}[#1] +}{\end{enumerate}} + +%embedded already sets a lot of values, see documentation +%in non-embedded mode, exercisesheets clears beamers headline +%and footline if non of the beamerwith...line arguments are used. +\usepackage[embedded]{exercisesheets} +\makeatletter +\exshset{ + strings/sheet={Missions}, + exercisespath=exercises, + subtask environment=stlist, + task restate font={\color{gray}}, + imp/.style={pointsinfo=important}, + vi/.style={pointsinfo=very important}, +} +\makeatother + +\parindent 0pt +\setlength{\parskip}{\baselineskip} + + + +\begin{document} +\begin{frame} +\maketitle +\end{frame} + +\section{Introduction} + +\begin{frame} + Let me tell you everything \pause\textbf{about embedding exercises}. +\end{frame} + +\section{Examples} + +\subsection{without a sheet environment} + + \begin{frame} + \begin{block}{} + Since our exercises are already in a dedicated subsection,\pause + we do not need an extra sheet environment. + \end{block} + \end{frame} + + \includeexercise*[imp]{exshexample-ex1} + \includeLexercise*[vi]{exshexample-ex2} + +\subsection{with a sheet environment} + +\begin{sheet}[note={The exercises are within a separated sheet + environment.}] + \includeexercise*[imp,solutions]{exshexample-ex1} +\end{sheet} + +\begingroup +\def\sheetfancy[#1]#2{\textcolor{red}{#2}}%nope, nothing happens +\exshset{sheet sectioning cmd=\sheetfancy} + +\begin{sheet}[note={This sheet header looks exactly like the first one, because \texttt{sheet sectioning cmd} is only used for +non-beamer documents.}] + \includeLexercise*[imp,solutions]{exshexample-ex2} +\end{sheet} +\endgroup + + +\end{document} + + diff --git a/Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample.tex b/Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample.tex new file mode 100644 index 00000000000..815b7d54af2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercisesheets/examples/exshexample.tex @@ -0,0 +1,286 @@ +\long\def\ifbeamer#1#2{#2} +\ifbeamer{\documentclass{beamer}}{\documentclass[a5paper]{article}} + +%navigation symbols and the title collide if +%beamerwithheadline is set +\ifbeamer{ + \setbeamertemplate{navigation symbols}{} +}{} + +%patchenumerate is the deafault +\usepackage[patchenumerate=true,beamerwithheadline, + %when directly messing with page breaks + %and the sheet start page actio (as we do below) + %using exercisesheets' page numer redefinitions per + %sheet do not make much sense + patchpagenumbers=false, + beamerwithfootline, + beamercompatibility, + exercisespath=exercises]% + {exercisesheets} +\usepackage{varioref} +\usepackage{hyperref} +\usepackage{xcolor} + +\exshset{solutions=true, +task restate font={\color{black!60}}, +only={1-3,5-}, +} + +%solutions may be printed out on paper -> a4 +%exercises are read on (smartphone) screen -> a5 +\ifsolutions{ + \usepackage[left=1cm,right=1cm,top=1cm,bottom=1.5cm,a4paper]{geometry} + }{ + \usepackage[left=0.7cm,right=0.7cm,top=1cm,bottom=1.5cm]{geometry} +} + +%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}}{} + + + + + +\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} + +\begingroup +\ifbeamer{}{ + \exshset{ + %default is \clearpage + sheet start page action={\pagebreak[3]\hrule}, + sheet end page action={\vspace{4mm}\hrule\vspace{2cm}}, + } +} + +%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. + \newpage + still done. + \end{solution} + \end{exercise} +\end{sheet} + +\endgroup + +%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. + Furt + \end{maintask} + \begin{subtasks} + \item {first \label{subex:skipexOneOne}} This is an \string\item\space inside a subtasks environment. If + \verb|subtask environment| is set to enumerate/itemize etc., + this works with some caveats (font settings for substaks are not used). + \subtask{second} + \end{subtasks} + \begin{enumerate} + \setcounter{enumi}{2} + \subtask {first \label{subex:skipexOne}} + This is a \string\subtask{} without the susbtasks + environment, which is unsupported and a bad example! + \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.}] + \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.}] + Some exercise, there are far too few. + \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.}] + \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/Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.pdf b/Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.pdf new file mode 100644 index 00000000000..5aed5c6aa19 Binary files /dev/null and b/Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.tex b/Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.tex new file mode 100644 index 00000000000..eb89c48b9e5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercisesheets/exercisesheets-doc.tex @@ -0,0 +1,1086 @@ +%% exercisesheets.tex +%% Copyright 2008-2024 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}, + texcs={def,let,renewcommand,long,begin,end,usepackage,ifdef}, + texcsstyle=\color{blue!60!gray}, + keywordstyle=\bfseries, + keywords={ + beamersolution, + exshset, + exercise, + hint, + includeexercise, + inexlabel, + ifnonoralsolutions, + iforalsolutions, + ifsamplesolutions, + ifsolutions, + Lexercise, + loadexercise, + maintask, + newframe, + points, + restatetask, + restatetaskbeamer, + sheet, + solution, + subexnref, + subexlref, + subtask, + subtasks, + TODO, + }, + keywordstyle=[2]\optionstyle, + keywords=[2]{ + bonus, + firstline, + framed, + inplace, + name, + only, + optional, + options, + oral, + strings, + solutionsby, + }, + identifierstyle=,%{}\color{red!60!gray}, + 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{\maybe}[1]{\textcolor{green!50!black}{#1}} +\newcommand{\mand}[1]{\textcolor{blue!50!black}{#1}} +\newcommand{\codestyle}{\normalfont\ttfamily\color{blue!50!black}} +\newcommand{\optionstyle}{\normalfont\ttfamily\color{red!50!black}} +\newcommand{\option}[1]{{\optionstyle #1}} +\newcommand{\optitem}[1][]{\item[{\codestyle #1}]} +\newcommand{\vers}[1]{{\normalfont\ttfamily\color{black!90} #1}} +\newcommand{\versitem}[1][]{\item[v. \vers{#1}]} +\newcommand{\filename}[1]{{\normalfont\ttfamily\color{magenta!80!black}#1}} +\newcommand{\binary}[1]{{\normalfont\ttfamily\color{yellow!50!black}#1}} +\newcommand{\luadisp}[1]{{\normalfont\ttfamily\color{cyan!50!black}#1}} + +\usepackage[english,iso]{isodate} +\title{The \exsh Package} +\author{Sebastian Kuhnert\and Frank Fuhlbrück} +\date{Version 0.17, \printdateTeX{2024/04/23}} + +\begin{document} +\maketitle + +The \exsh package provides a way to typeset exercise sheets as used in university courses and school classes. It evolved from a set of macros an environments that were finally combined into this package. Starting from Version \vers{0.7}, there was an alternative variant designed for use with the beamer class, which is integrated into the main package since version \vers{0.11}. Not all combinations of options have been tested with the beamer variant. From version \vers{0.16} on, there is an embedded mode that allows using exercise in lecture notes etc. without requiring page breaks. Since the package includes a loading mechanism for exercises in external files, the same exercises can be reused in different contexts. + + +\subsection*{Licence} +Copyright \textcopyright{} 2008--2024 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{Reading this Document} + +\begin{itemize} + \item All macros and environments defined by this package are + printed in bold like this: \lstinline|\points| and + \lstinline|\begin{sheet}\end{sheet}|. + \item Key-value style options with a mandatory argument are + printed like this: {\codestyle \option{only}=\param{list of ranges}}, while optional (usually boolean) arguments + look like this: {\codestyle \option{embedded}\maybe{=\param{true/false}}}. +\end{itemize} + + + + +\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 (in its standard setting) + 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. + \item The \texttt{xsim} (and its predecessor \texttt{exsheets}) package also offers a similar set of features for the average user. It also has a mechanism for hiding certain exercises and solutions that works a bit differently than the mechanism of + this package. There is (to my knowledge) no explicit beamer support. +\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 (you can override this). + \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 + \lstinline|\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 \lstinline|\numberwithin|) + \item \texttt{iflualatex} + \item \texttt{refcount} (for \lstinline|\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(*\maybe{[\param{options}]}*){exercisesheets} +\end{lstlisting} + +The following options are available: +\begin{description} + \optitem[{\option{only}=\mand{\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} + \optitem[{\option{only}=3}] Only include the 3rd sheet of the document. + \optitem[{\option{only}=\{1,3,5,7\}}] Only include the sheets 1, 3, 5 and 7. + \optitem[{\option{only}=last}] Only include the last sheet of the document. + \optitem[{\option{only}=\{3-5,8-last\}}] Exclude the sheets 1, 2, 6 and 7. + \optitem[{\option{only}=\{-2,5-\}}] Exclude the sheets 3 and 4. + \end{description} + \optitem[{\option{all}}] Typeset all sheets (equivalent to \option{only=-}). This is + the default. + \optitem[{\option{solutions\maybe{=\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. + \optitem[{\option{gradingguides\maybe{=\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). + \optitem[{\option{solutionsby}=\mand{\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. + \optitem[{\option{language}=\mand{\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. + \optitem[{\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. + \optitem[{\option{exercisespath}}] Set the (relative) path of the + directory containing exercises to be included via + \lstinline|\includeexercise|. + \optitem[{\option{patchenumerate}\maybe{=\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 (\lstinline|enumitem|, \lstinline|paralist|) the mechanism + slightly differs. This option is active by default. + \optitem[{\option{settitle}\maybe{=\param{true/false}}}] If set to true + (which is the default), + the document \lstinline|\title| will be automatically set to the value + of \option{strings/sheets} and the value of \option{strings/solutions} will be + appended if \option{solutions} is not \lstinline|false|. + \optitem[{\option{patchpagenumbers}\maybe{=\param{true/false}}}] If true + (default), pages will be numbered within sheets and page numbers + get a prefix of the form ``{\codestyle\param{sheet number}-}''. + \optitem[{\option{usestartsection}\maybe{=\param{true/false}}}] If true + (default), the command \lstinline|\@startsection| is used to create + the header of any exercise as a section, which (among other + things) adds an entry to the TOC (if existent) at level 1 + (usually corresponding to \lstinline|\section|). + \optitem[{\option{embedded}\maybe{=\param{true/false}}}] Default: false. + Embedded mode allows for exercise ``sheets'' which do not + interfere with a surrounding document. More explicitly, it does + not interfere with \lstinline|secnumdepth|, defines special counters + \lstinline|exshsheet| and \lstinline|exshexercise| to use them for + \option{sheet counter} and \option{exercise counter}, + respectively and sets all of \option{patchenumerate}, + \option{settitle}, \option{patchpagenumbers} and + \option{usestartsection} to \lstinline|false|. + An internally defined macro which basically does no extra + formatting or adding anything to the TOC is used as + \option{sheet sectioning cmd} instead of the usual \lstinline|\part|. + Finally, + the \option{sheet start page action} and the + \option{sheet end page action} are both set to \lstinline|\relax|. + If you want to override any of this, do it after setting + \option{embedded} to \lstinline|true|. + \item{\option{minskips\maybe{=\param{true/false}}}} Default: false. + If true, the values of + \option{above sheet title skip}, + \option{below sheet header skip}, + \option{above first exercise skip} and + \option{below exercise title skip} are all set to 0pt. + \optitem[{\option{showtodos} / \option{hidetodos}}] + \lstinline|\TODO| markers + are hidden by default, this option switches their behavior. This + option is usually set within \lstinline|\ifsamplesolutions| or + similar. + \optitem[{\option{beamercompatibility}\maybe{=\param{true/false}}}] + This option (which only is effective in the non-beamer version) + defines several beamer macros with as trivial + effects as possible, e.g., \lstinline|\pause| becomes \lstinline|\relax| + and overlay specifications are mostly ignored. Be careful to use + this option after loading \lstinline|enumitem| etc. as the enumerate + and itemize environment are defined to swallow overlay + specifications without effect, this also holds for + \lstinline|\item<1->|. If you load \lstinline|exercisesheets| before them + use \lstinline|\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} + +\optitem[{\option{filenameasexercisename}\maybe{=\param{true/false}}}] +This option (set to false by default) causes +\lstinline|\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). If you want to set the title yourself, set the +option \option{settitle} to \lstinline|false|. + +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} + \optitem[{\option{exauthor}=\mand{\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}(*\maybe{[\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} + \optitem[{\option{date}=\mand{\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. + \optitem[{\option{note}=\mand{\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 + \lstinline|\protect\linebreak|. + \optitem[{\option{title}=\mand{\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). + \optitem[{\option{number within sheet\maybe{=\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. + \optitem[{\option{author}=\mand{\param{author}}}] Set the author included in the sheet + head. By default, the value passed to \lstinline|\author| is used. + \optitem[{\option{exauthor}=\mand{\param{exauthor}}}] Only used by the beamer + variant, see above. + \optitem[{\option{subject}=\mand{\param{subject}}}] Set the subject included in the sheet + head. By default, the value passed to \lstinline|\subject| is used. + \optitem[{\option{semester}=\mand{\param{semester}}}] Set the semester included in the + sheet head. By default, the value passed to \lstinline|\date| is used. + \optitem[{\option{beamerwithheadline\maybe{=\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. If you specify the embedded option the current default headers and footers will be used if you omit this option. Otherwise omitting it will imply an empty headline. + \optitem[{\option{beamerwithfootline\maybe{=\param{true/false}}}}] + The same for the footer. + \optitem[{\option{beameruseblocks\maybe{=\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}(*\maybe{[\param{options}]}*) + (*\param{exercise text}*) + \begin{solution}(*\maybe{[\param{solution options}]}*) + (*\param{solution text}*) + \end{solution} + \begin{beamersolution}(*\maybe{[\param{solution options}]}*) + (*\param{solution text}*) + \end{beamersolution} +\end{exercise} +\end{lstlisting} + +This inserts an exercise into the current document. All +\lstinline|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} + \optitem[{\option{name}=\mand{\param{text}}}] Use \param{text} as the name of the exercise. + Useful for exercises that prove a famous theorem. + \optitem[{\option{firstline}=\mand{\param{text}}}] Save some space by text \param{text} + behind the exercise title. + \optitem[{\option{savetasks\maybe{=\param{true/false}}}}] Saves the main task and each sub task + for later use with \lstinline|\restatetask[|% + \param{which}], where \param{which} is either \lstinline|main| + (default) or the number of a sub task. + \optitem[{\option{points}=\mand{\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 \lstinline|\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 \filename{.aux} file or explicitly use + \lstinline|\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. + \optitem[{\option{oral}}] Label this exercise as \emph{oral}. This supersedes and is + superseded by the option \option{points}. + \optitem[{\option{pointsinfo}=\mand{\param{text}}}] Supply \param{text} as additional + information to be displayed after the points. + \optitem[{\option{optional}}] Shortcut for \option{pointsinfo=optional} with + automatic translation and abbreviation (if requested). + \optitem[{\option{bonus}}] Change \enquote{points} to \enquote{bonus points} (with + automatic translation and abbreviation). + \optitem[{\option{abbrev}}] Use abbreviated labels. + \optitem[{\option{exercisemark}=\mand{\param{symbol}}}] Mark the exercise + with \param{symbol} in the left margin. + \optitem[{\option{difficult}}] Shortcut for \option{exercisemark=*}. + \optitem[{\option{solutions\maybe{=\param{true/false/oral/nonoral/...}}}}] Use this to override the + document (or sheet) default. + \optitem[{\option{sample}}] Include this exercise (and its solution) in while compiling + sample solutions. + \optitem[{\option{beamersolution}}] For beamer variant only. If this option + is set all normal solutions will not be included and only + \lstinline|beamersolution|s are typeset. + \optitem[{\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 \lstinline|\newframe| to start a new frame. This + option is especially helpful if you provide your own definitions + of \lstinline|\only| etc. and/or use the \option{beamercompatibility}. + for non-beamer compilation. \lstinline|\newframe| + is already defined as \lstinline|\relax| in non-beamer \exsh, + even without invoking \option{beamercompatibility}. + \optitem[{\option{fragile}}] For beamer variant only and only + used combined with framed, simply ignored elsewhere. Frames are + declared as \texttt{fragile} und parsing of \lstinline|\newframe| + etc. is done via Lua\LaTeX. Thus Lua\LaTeX is required + (and this requires font setup via fontspec etc.), but + you do not have to use any Lua code yourself. Mostly useful + for listings and other verbatim stuff within solutions. +\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}(*\maybe{[\param{options}]}*) + (*\param{hint text}*) +\end{hint} +\end{lstlisting} + +\begin{lstlisting} +\begin{hint*}(*\maybe{[\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}[(*\option{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 +\lstinline|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 original task and a part of the solution might be on different slides. In the future it might be possible to +use other counters then \lstinline|enumi|, which is also only possible +if sub-exercises are not simply \lstinline|\item|s in +\lstinline|enumerate|. If you want to reuse the main or any subtasks +you may use \lstinline|\restatetask| or \lstinline|\restatetaskbeamer| +(this shows noting if not compiled with beamer). There is also +a starred version (\lstinline|\restatetask*| / +\lstinline|\restatetaskbeamer*|) for each of them, which adds a newline. +All four have an optional argument that allows to restate +a subtask instead of the main task. This argument is either +\lstinline|main|, a number of a \textbf{previous} subtask or +\lstinline|cur| for the current subtask. Using \option{headerrestate} +for your solution will automatically restate the current +task within the beamer solution header (does noting without +beamer). + + + +\begin{lstlisting} +\begin{exercise}[(*\option{points}*)=oral] + \begin{maintask} + A and B are true. + \end{maintask} + \begin{subtasks} + \subtask{A is true} + \begin{solution}[framed] + We want to show: \restatetask %A and B are true. + \newframe + Out first step is to show: \restatetask[cur] %A is true + \end{solution} + \subtask{If A is true, B is true.} + \begin{solution}[framed] + Obvious (i.e.: homework). + \end{solution} + \subtask{B is true} + \begin{solution}[framed] + We already know: \restatetask[1] and + \restatetask[2], therefore B is also true. + \end{solution} + \end{subtasks} +\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 \lstinline|\subexnref| and +\lstinline|\subexlref| are designed for. However, both of them still +require an ordinary label, which is not allowed in +exercises loaded with \lstinline|\loadexercise*|. +For this purpose \lstinline|\inexlabel| can be used which is just a +normal label that is not redefined to produce an error. +Furthermore, we define a counter \lstinline|subex| (which is +currently just an alias for enumi, but this might change). You can +use this counter (alias) with common commands like +\lstinline|\arabic| or \lstinline|\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 \lstinline|\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} + \optitem[{\option{strings/sheet}=\mand{\param{string}}}] + \optitem[{\option{strings/sheets}=\mand{\param{string}}}] + \optitem[{\option{strings/solutions}=\mand{\param{string}}}] + \optitem[{\option{strings/solutionsby}=\mand{\param{string}}}] + \optitem[{\option{strings/exercise}=\mand{\param{string}}}] + \optitem[{\option{strings/solution}=\mand{\param{string}}}] + \optitem[{\option{strings/hint}=\mand{\param{string}}}] + \optitem[{\option{strings/oral}=\mand{\param{string}}}] + \optitem[{\option{strings/oral abbrev}=\mand{\param{string}}}] + \optitem[{\option{strings/point}=\mand{\param{string}}}] + \optitem[{\option{strings/points}=\mand{\param{string}}}] + \optitem[{\option{strings/points abbrev}=\mand{\param{string}}}] + \optitem[{\option{strings/bonus point}=\mand{\param{string}}}] + \optitem[{\option{strings/bonus points}=\mand{\param{string}}}] + \optitem[{\option{strings/bonus points abbrev}=\mand{\param{string}}}] + \optitem[{\option{strings/optional}=\mand{\param{string}}}] + \optitem[{\option{strings/optional abbrev}=\mand{\param{string}}}] +\end{description} + +Example: Give an introduction that should only be included in the version with +solutions: + +\begin{lstlisting} +\begin{solution}[(*\option{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} + \optitem[{\option{sheet header font}}] The basic font for subject, author, semester, + date, note and solution authors in the sheet headers.\\ + Default: \lstinline|\normalfont\normalsize| + \optitem[{\option{subject font}}] The font for the subject in the sheet header.\\ + Default: \lstinline|\scshape| + \optitem[{\option{author font}}] The font for the author in the sheet header.\\ + Default: \lstinline|\scshape| + \optitem[{\option{semester font}}] The font for the semester in the sheet header.\\ + Default: empty, i.\,e.\ no change. + \optitem[{\option{date font}}] The font for the date in the sheet header.\\ + Default: empty, i.\,e.\ no change. + \optitem[{\option{solutionsby font}}] The font for the information who has produced + the solutions provided below the sheet title.\\ + Default: \lstinline|\itshape| + \optitem[{\option{sheet note font}}] The font for the note provided below the sheet + title.\\ + Default: \lstinline|\itshape\bfseries| + \optitem[{\option{sheet title font}}] The font for the sheet title itself.\\ + Default: \lstinline|\Large\bfseries| + \optitem[{\option{exercise title font}}] The font for the exercise title.\\ + Default: \lstinline|\bfseries| + \optitem[{\option{points font}}] The font for the number of points in the exercise + head (relative to the exercise title) and for \lstinline|\points|.\\ + Default: \lstinline|\itshape| + \optitem[{\option{main task font}}] The font for the + \lstinline|maintask| environment.\\ + Default: empty, i.\,e.\ no change. + \optitem[{\option{subtask font}}] The font for each + \lstinline|\subtask|.\\ + Default: empty, i.\,e.\ no change. + \optitem[{\option{task restate font}}] The font used for + \lstinline|\restatetask|.\\ + Default: \lstinline|\itshape| + \optitem[{\option{hint font}}] The font for hints. \\ + Default: empty, i.\,e.\ no change. + \optitem[{\option{hint title font}}] The font for the string \enquote{Hint:}.\\ + Default: \lstinline|\itshape| + \optitem[{\option{solution font}}] The font for solutions.\\ + Default: empty, i.\,e.\ no change. + \optitem[{\option{solution title font}}] The font for the string + \enquote{Solution:}\\ + Default: \lstinline|\bfseries| + \optitem[{\option{grading guide font}}] The font for grading guides.\\ + Default: \lstinline|\itshape| + \optitem[{\option{todo marker font}}] The font for the string \enquote{TODO}.\\ + Default: \lstinline|\ifdef{\color}{\color{red}}{}\bfseries| +\end{description} + +\subsection{Controlling the Spacing, Page Handling and Separations between Elements} + +The following options allow fine-tuning of the spacing: +\begin{description} + \optitem[{\option{below slide headline skip}=\mand{\param{dimen}}}] The distance between + haedline (if present) and slide content. Only used by beamer + variant, ignored elsewhere.\\ + Default: \texttt{0mm} + \optitem[{\option{above sheet title skip}=\mand{\param{dimen}}}] The distance between + author/date and sheet title.\\ + Default: \texttt{4ex} + \optitem[{\option{above sheet note skip}=\mand{\param{dimen}}}] The distance above the + sheet note.\\ + Default: \texttt{.7ex} + \optitem[{\option{above solutionsby skip}=\mand{\param{dimen}}}] The distance above the + solution author.\\ + Default: \texttt{1ex} + \optitem[{\option{below sheet header skip}=\mand{\param{dimen}}}] The distance below the + sheet header.\\ + Default: \texttt{4ex plus 1ex minus .5ex} + \optitem[{\option{above exercise skip}=\mand{\param{dimen}}}] The distance above + exercises.\\ + Default: \texttt{3ex plus 1ex minus .5ex} + \optitem[{\option{below exercise title skip}=\mand{\param{dimen}}}] The distance below + exercise titles.\\ + Default: \texttt{\textbackslash parskip} + \optitem[{\option{above solution skip}=\mand{\param{dimen}}}] The distance above + solutions.\\ + Default: \texttt{1ex} + \optitem[{\option{above hint skip}=\mand{\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} + \optitem[{\option{sheet start page action}=\mand{\param{macro}}}] Executed at the beginning + of each sheet.\\ + Default: \lstinline|\clearpage| + \optitem[{\option{sheet end page action}=\mand{\param{macro}}}] Executed at the end + of each sheet.\\ + Default: \lstinline|\clearpage| +\end{description} + +The following option controls what follows after the string +\option{strings/solution} within a solution header. Using this, you can disable a solution header completely or, for instance, add +a horizontal bar below each solution title. +\begin{description} + \optitem[{\option{solution title separator}=\mand{\param{content}}}] Inserted directly after \option{strings/solution} in a solution title:\\ + Default: \lstinline|:\par| +\end{description} + +\subsection{Controlling the Sectioning (beta)} + +By default, exercises are sections and sheets are parts. They use +the respective counters and commands. This is impractical, if you +want to include exercise ``sheets'' as, e.g., a subsection within +a section of a book or article. While the page handling options +already allow to dismiss page breaks, sectioning commands might +still break your layout or structure. Since version \vers{0.15} you +can use your own counters and commands to start sheets and +(to a certain degree) exercises. Exercises are currently still +started by \lstinline|\@startsection| with the counter set to +\option{exercise counter}, but the level set to 1 (e.g. section). +This will likely change with one of the next versions, but needs +some testing. Thus, if you use any of these options, watch for +undesired consequences and report them via gitlab if possible. + +\begin{description} + \optitem[{\option{sheet sectioning cmd}=\mand{\param{macro}}}] This macro is + called only in one place in the following way: + \lstinline|\macro[short title]{long title}|, so it + must take one argument in [brackets] and one normal argument.\\ + Default: \lstinline|\part| + \optitem[{\option{sheet counter}=\mand{\param{counter}}}] This counter will be + incremented wit every sheet. There was always an internal counter + \lstinline|sheetid| used to distinguish sheets for hyperref even if + \lstinline|part|s value changed. Do not use this counter here, as it will have strange effects (incremented twice).\\ + Default: \lstinline|part| + \optitem[{\option{exercise counter}=\mand{\param{counter}}}] This counter will + be incremented wit every exercise (usually within each sheet). + Default: \lstinline|section| +\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}*)} +\ifsamplesolutions{(*\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}[(*\option{ifsolutions}*)={}{(*\option{above title skip}*)=2ex}]% usually 4ex + \dots +\end{sheet} +\end{lstlisting} + +\subsection{Using Hooks} +There are several hooks used by \exsh: +\begin{description} + \optitem[{\option{every sheet}}] This is used at the beginning of every sheet. + \optitem[{\option{every exercise}}] This is used at the beginning of every exercise. + \optitem[{\option{every solution}}] This is used at the beginning of every solution. + \optitem[{\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} + \optitem[{\option{custom skip macro}=\mand{\param{macro}}}] +\end{description} + +If an exercise is not printed, some macros like \lstinline|\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 \lstinline|\ifstrequal|s and then either +executes a custom skipper, replaces your macro with +the standard version or uses \lstinline|\expandafter| to +deliver the expanded version of your macro to +\lstinline|\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 \vers{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 makefile that generates +\texttt{solutions.tex} as a temporary file. + +\subsection{Compatibilty with make4ht and tex4ebook} +Since version \vers{0.15} this package can be used with make4ht and tex4ebook in non-beamer mode. Some code for the sheet and exercise header already provides a similar alignment as when producing PDF files. If your goal is an exercise (or solution) document within a single HTML file that looks as similar to the PDF as possible, consider \url{https://tex.stackexchange.com/questions/605478/}, \url{https://tex.stackexchange.com/questions/662445} and \url{https://tex.stackexchange.com/questions/630992}. + +\section{Changelog} +\label{sec:changelog} + +\begin{itemize} + \versitem[0.17:] 2024-04-23 + \begin{itemize} + \item Make embedded mode work better with beamer. This + includes not overriding headlines and footlines and + incrementing the frame counter for non-frames. + \item issue an explicit warning if \string\subtask is outside of a subtasks environment + \item clearify documentation and use consistent styling + \item additional example for embedding exercises + \end{itemize} + \versitem[0.16:] 2024-03-07 + \begin{itemize} + \item Embedded mode and most of the additional options it + automatically sets. + \end{itemize} + \versitem[0.15.1:] 2023-12-14 + \begin{itemize} + \item bugfix: beamer support was broken in \vers{0.15} due to + a missing macro. + \end{itemize} + \versitem[0.15:] 2023-11-30 + \begin{itemize} + \item new option \option{solution title separator} + (initially set to\lstinline|:\par|). Among other things, this + allows for solutions without any caption or header by + setting \option{solution title separator},~ + \option{solution title font} as well as + \option{strings/solution} to \lstinline|\relax|. + \item initial support for \binary{make4ht} and + \binary{tex4ebook} by avoiding certain behavior when these + modes are used. Note that both are incompatible with beamer + mode. + \item initial decoupling of exercise and sheet from + sections and parts using the new options (defaults in + parenthesis) \option{sheet sectioning cmd} (\lstinline|\part|), + \option{sheet counter} (\lstinline|part|) and + \option{exercise counter} (\lstinline|section|). + \end{itemize} + \versitem[0.14:] 2023-02-06 + \begin{itemize} + \item new option \option{headerrestate} to restate + the current (if in subexercise) or main task within + a solutions header + \item bugfix: \lstinline|\restatetask| etc. give meaningful error if \option{savetasks} is not set. + \end{itemize} + \versitem[0.13.1:] 2022-11-22 + \begin{itemize} + \item bugfix: \lstinline|\detokenize| filenames when + \option{filenameasexercisename} is active as otherwise, + e.g., underscores would not be allowed in filenames. + \end{itemize} + \versitem[0.12.2:] 2022-10-20 + \versitem[0.13:] 2022-11-07 + \begin{itemize} + \item bugfix: \lstinline|\begingroup| and \lstinline|\endgroup| + within \lstinline|\subtask| now contain everything up to the + next \lstinline|\subtask|. + \item \lstinline|\restatetask| has now a starred version that + adds a newline and beamer versions for both the + regular and the starred version. Furthermore, there + is an argument \option{cur} to restate the current + subtask (the one just given before). This is only + defined within the aforementioned group, i.e., + throws an error after \lstinline|\end{subtasks}|. + \end{itemize} + \versitem[0.12.2:] 2022-10-20 + \begin{itemize} + \item bugfix: \luadisp{dofile} with + \luadisp{kpse.find\_file} + \item docs: document option \option{fragile} + \end{itemize} + \versitem[0.12.1:] 2022-10-19 + \begin{itemize} + \item bugfix for \lstinline|\begin{enumerate}[<+->]| + \end{itemize} + \versitem[0.12:] 2022-09-02 + \begin{itemize} + \item new option \option{beamerwithfootline} + \end{itemize} + \versitem[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 requires 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/Master/texmf-dist/tex/latex/exercisesheets/exercisesheets.sty b/Master/texmf-dist/tex/latex/exercisesheets/exercisesheets.sty new file mode 100644 index 00000000000..34a68ce6a7b --- /dev/null +++ b/Master/texmf-dist/tex/latex/exercisesheets/exercisesheets.sty @@ -0,0 +1,1961 @@ +%% exercisesheets.sty +%% Copyright 2008-2023 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.17} +\def\exsh@date{2024/04/23} + +\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@html +\@ifclassloaded{tex4ht}{\exsh@htmltrue}{} +\ifdefined\HCode + \exsh@htmltrue +\fi +\ifexsh@html + \def\exsh@inshtml#1{\HCode{#1}} +\else + \def\exsh@inshtml#1{} +\fi + +\newif\ifexsh@patchenumerate\exsh@patchenumeratetrue +\newif\ifexsh@settitle\exsh@settitletrue +\newif\ifexsh@patchpagenumbers\exsh@patchpagenumberstrue +\newif\ifexsh@patchheadandfoot\exsh@patchheadandfoottrue +\newif\ifexsh@usestartsection\exsh@usestartsectiontrue +\newif\ifexsh@firstexonsheet +\def\exsh@firstexonsheettrue{\global\let\ifexsh@firstexonsheet\iftrue} +\def\exsh@firstexonsheetfalse{\global\let\ifexsh@firstexonsheet\iffalse} +\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@headerrestate +\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, + settitle/.is if=exsh@settitle, + settitle/.default=true, + patchpagenumbers/.is if=exsh@patchpagenumbers, + patchpagenumbers/.default=true, + usestartsection/.is if=exsh@usestartsection, + usestartsection/.default=true, + embedded/.code={% + \exsh@patchenumeratefalse + \exsh@settitlefalse + \exsh@patchpagenumbersfalse + \exsh@patchheadandfootfalse + \exsh@usestartsectionfalse + \pgfkeysalso{secnumdepth=keep}% + \def\exhs@sheetnoheader[##1]##2{}% + \newcounter{exshsheet} + \newcounter{exshexercise} + \pgfkeysalso{ + sheet sectioning cmd=\exhs@sheetnoheader, + sheet counter=exshsheet, + exercise counter=exshexercise, + sheet start page action=\relax, + sheet end page action=\relax, + }% + }, + minskips/.code={% + \pgfkeysalso{ + above sheet title skip=0pt, + below sheet header skip=0pt, + above first exercise skip=0pt, + below exercise title skip=0pt, + }% + }, + 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, + headerrestate/.is if=exsh@headerrestate, + headerrestate/.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}, + headerrestate/.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}, + headerrestate/.default={ignore}, + headerrestate/.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, + settitle/.initial=true, + patchpagenumbers/.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={}, + % + % sectioning cmds and counters for sheet and exercise + % sheet sectioning cmd must take an optional + % and a mandatory argument + sheet sectioning cmd/.initial={\part}, + sheet counter/.initial={part}, + secnumdepth/.initial={-1}, + exercise counter/.initial={section}, + % + % 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, + solution title separator/.initial={:\par}, + 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}, + above first 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{\pgfkeysvalueof{/exsh/sheet counter}}}}% +} + +\ifexsh@patchpagenumbers + \numberwithin{page}{\pgfkeysvalueof{/exsh/sheet counter}} + \renewcommand{\thepage}{\arabic{page}}%changed for every sheet +\fi +\ifthenelse{\equal{\pgfkeysvalueof{/exsh/secnumdepth}}{keep}}{}{ + \setcounter{secnumdepth}{\pgfkeysvalueof{/exsh/secnumdepth}} +} + +\AfterPackage*{hyperref}{% + % make PDF destinations unique: + \def\theHsection{\arabic{sheetid}.\arabic{\pgfkeysvalueof{/exsh/exercise counter}}}% + \ifexsh@patchpagenumbers + \def\theHpage{\arabic{sheetid}-\arabic{page}}% + \fi + % + % open bookmarks when typesetting a single sheet + \AtEndPreamble{% + \exsh@checkrange{0}% + \ifexsh@singularrange\hypersetup{bookmarksopen}\fi + }% +} + + +\ifexsh@settitle +% 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 +} +\else + \def\exsh@write@title#1{} +\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{\pgfkeysvalueof{/exsh/sheet counter}}+1}% + \edef\exsh@temp{\expandonce{\pgfkeysvalueof{/exsh/strings/sheet}}\noexpand~\exsh@tmp}% + \pgfkeys{/exsh/title/.expand once={\exsh@temp}}% + \ifexsh@patchpagenumbers + \def\thepage{\arabic{\pgfkeysvalueof{/exsh/sheet counter}}-\arabic{page}}% + \fi + }{% + \ifexsh@patchpagenumbers + \def\thepage{\arabic{page}}% + \fi + }% + \ifexsh@exnumsheet + \edef\exsh@exnumstore{\arabic{\pgfkeysvalueof{/exsh/exercise counter}}} + \setcounter{\pgfkeysvalueof{/exsh/exercise counter}}{0}% + \fi + \numdef\exsh@tmp{\value{\pgfkeysvalueof{/exsh/sheet counter}}+1}% + \exsh@checkrange{\exsh@tmp}% + \ifexsh@isinrange + \ifexsh@singularrange + \pgfkeysgetvalue{/exsh/title}{\exsh@temp}% + \exsh@write@title{\exsh@temp}% + \fi + \exsh@sheethead + \else + \refstepcounter{\pgfkeysvalueof{/exsh/sheet counter}}% + \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{\pgfkeysvalueof{/exsh/exercise counter}}{\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: --------------------------------------- + \ifexsh@html + \let\exsh@hyper@itemtrue\relax% + \else + \def\exsh@hyper@itemtrue{\@hyper@itemtrue}% + \fi +\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{\pgfkeysvalueof{/exsh/exercise counter}}% + % 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{\pgfkeysvalueof{/exsh/exercise counter}} + \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{\pgfkeysvalueof{/exsh/sheet counter}}% + \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} +} +\global\def\exsh@alignright#1{\hfill #1}% +\else%--------- NON-BEAMER: --------------------------------------- +\ifexsh@html +% \global\def\exsh@part[#1]#2{#2} +% \exshset{sheet sectioning cmd/.initial={\exsh@part}} + \global\def\exsh@alignright#1{% + \exsh@inshtml{}#1% + \exsh@inshtml{} + } + \global\def\exsh@centering#1{% + \exsh@inshtml{}#1% + \exsh@inshtml{} + } +\else + \global\def\exsh@alignright#1{\hfill #1}% + \global\def\exsh@centering#1{\centering #1} +\fi +\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{\pgfkeysvalueof{/exsh/sheet counter}}% + \pgfkeysvalueof{/exsh/sheet sectioning cmd}[\pgfkeysvalueof{/exsh/title}]{\normalsize + \pgfkeysvalueof{/exsh/sheet header font}% + \begingroup\raggedright% + {\pgfkeysvalueof{/exsh/subject font}\pgfkeysvalueof{/exsh/subject}}% + \exsh@alignright{\pgfkeysvalueof{/exsh/semester font}% + \pgfkeysvalueof{/exsh/semester}% + }\\ + {\pgfkeysvalueof{/exsh/author font}\exsh@author}% + \exsh@alignright{ + \pgfkeysvalueof{/exsh/date font}\pgfkeysvalueof{/exsh/date}% + }\\ + \vskip\pgfkeysvalueof{/exsh/above sheet title skip}\relax% + \endgroup + \begingroup + \exsh@centering{\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 + \exsh@centering{\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 + \exsh@centering{\pgfkeysvalueof{/exsh/note}\\}\unskip% + \endgroup + }% + }% + \endgroup + }% + \ifdim\z@=\pgfkeysvalueof{/exsh/below sheet header skip}\relax + \vskip-\parskip + \else + \unskip\vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax + \fi +% \unskip +% \vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax + \exsh@firstexonsheettrue + \ifexsh@patchpagenumbers% + \stepcounter{page}% + \fi +}% +\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{\pgfkeysvalueof{/exsh/exercise counter}}+1\endcsname + \edef\exsh@sumpts{% + \csname exsh@sumpts@\the\numexpr\arabic{\pgfkeysvalueof{/exsh/exercise counter}}+1% + \endcsname% + }% + \edef\exsh@sumptsbonus{% + \csname exsh@sumptsbonus@\the\numexpr\arabic{\pgfkeysvalueof{/exsh/exercise counter}}+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{off}{\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{ +% \exsh@inshtml{}\hfill +% \enskip\exsh@alignright\bgroup% +% \pgfkeysvalueof{/exsh/points font}}% +% \appto\exsh@points{\egroup\exsh@inshtml{}}% + \edef\exsh@points{\exsh@alignright{% + \pgfkeysvalueof{/exsh/points font}\expandonce\exsh@points + }} + }% + \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{\pgfkeysvalueof{/exsh/exercise counter}}% + \edef\exsh@tmp{[\pgfkeysvalueof{/exsh/strings/exercise} \arabic{\pgfkeysvalueof{/exsh/exercise counter}}\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@startheader\exsh@tmp{\noindent% + \hbox to 0pt{\hss\pgfkeysvalueof{/exsh/exercisemark}}% + \pgfkeysvalueof{/exsh/strings/exercise}~\arabic{\pgfkeysvalueof{/exsh/exercise counter}}\exsh@exname\exsh@firstline\expandonce\exsh@points}% + \ifdim\z@=\pgfkeysvalueof{/exsh/below exercise title skip}\relax + \vskip-\parskip + \else + \unskip\vskip\pgfkeysvalueof{/exsh/below exercise title skip}\relax + \fi + \@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{\pgfkeysvalueof{/exsh/exercise counter}}\endcsname{% + \arabic{exsh@pts@cur}% + }% + \string\expandafter\gdef% + \detokenize{\csname} exsh@sumptsbonus@\arabic{\pgfkeysvalueof{/exsh/exercise counter}}\endcsname{% + \arabic{exsh@ptsbonus@cur}% + }% + }% + \fi + \ifexsh@beamer\clearpage\fi%%%% <<<< 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{\pgfkeysvalueof{/exsh/sheet counter}}.\arabic{\pgfkeysvalueof{/exsh/exercise counter}}.\arabic{enumi}} +%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ifexsh@beamer + % code below breaks [] argument after \begin{enumerate} + % when beamer is used + % in beamer we set item labels separately + % see beamer specific def. of \exsh@startheader +\else%--------- NON-BEAMER: --------------------------------------- + \AtEndPreamble{% + \@ifpackageloaded{paralist}{}{% + \@ifpackageloaded{enumitem}{}{% + \apptocmd{\enumerate}{ + \ifnum\@enumdepth=1% + \def\labelenumi{(\alph{enumi})} + \def\labelenumii{\arabic{enumii}.} + \def\labelenumiii{\roman{enumiii}.} + \fi + }{}{}% + }% + }% + }% +\fi +%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\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}{\pgfkeysvalueof{/exsh/exercise counter}} + +\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} + \def\exsh@ifwithinsubt##1##2{##1} + \ignorespaces\begingroup +}{ + \endgroup + \end{\exsh@subtaskenv}% +} + +\def\exsh@ifwithinsubt#1#2{#2} + +\def\exsh@ensuressubtasks{% + \exsh@ifwithinsubt{ + \endgroup\begingroup + }{% + \PackageWarning{exercisesheets}{% + Using \subtask\space without a subtasks environment + is unsupported + }{}% + }% +} + +\newcommand{\subtask}[2][]{% + \exsh@ensuressubtasks + \pgfkeys{exsh,#1}% + \csname\exsh@subtaskitm\endcsname% + {\pgfkeysvalueof{/exsh/subtask font} #2}% + \ifbool{exsh@savetasks}{% + \csgdef{exsh@restatetask\arabic{\exsh@subtaskctr}}{#2}% + \csdef{exsh@restatetaskcur}{#2}% + }{}% +} + +\def\exsh@ensuresavetasks{% + \ifbool{exsh@savetasks}{}{% + \PackageError{exercisesheets}{% + If you want to restate something, you have to % + use the option savetasks.% + }{}% + }% +} + +\def\restatetask{% + \exsh@ensuresavetasks% + \@ifstar\exsh@restatetask@\exsh@restatetask% +} + +\newcommand{\exsh@restatetask}[1][main]{% + {\pgfkeysvalueof{/exsh/task restate font}% + \csname exsh@restatetask#1\endcsname}% +} + +\newcommand{\exsh@restatetask@}[1][main]{% + {\pgfkeysvalueof{/exsh/task restate font}% + \csname exsh@restatetask#1\endcsname}\\% +} + +%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ifexsh@beamer + \let\restatetaskbeamer\restatetask +\else%--------- NON-BEAMER: --------------------------------------- + \def\restatetaskbeamer{% + \@ifstar\exsh@restatetaskbeamer\exsh@restatetaskbeamer% + } + \newcommand{\exsh@restatetaskbeamer}[1][main]{} +\fi +%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\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{\pgfkeysvalueof{/exsh/exercise counter}}% + \ifnum\@enumdepth>0\alph{subex}\fi)} % + \ifbool{exsh@headerrestate}{ + \exsh@ensuresavetasks + \csname exsh@restatetask% + \ifnum\@enumdepth>0cur\else main\fi% + \endcsname% + }{}% + \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{\pgfkeysvalueof{/exsh/exercise counter}}% + \ifnum\@enumdepth>0\alph{subex}\fi)} % + \ifbool{exsh@headerrestate}{ + \exsh@ensuresavetasks + \csname exsh@restatetask% + \ifnum\@enumdepth>0cur\else main\fi% + \endcsname% + }{}% + \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]{} +` \unskip\vskip1pt\vskip-\parskip + \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 + \ifbool{exsh@framed}{}{\clearpage\stepcounter{framenumber}} + \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{\pgfkeysvalueof{/exsh/exercise counter}}% +% \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}% + \pgfkeysvalueof{/exsh/solution title separator}% + }\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 +\ifexsh@patchheadandfoot + \setbeamertemplate{headline}{}% + \setbeamertemplate{footline}{}% +\fi +\ifbool{exsh@beamerwithheadline}{% + \setbeamertemplate{headline}{% +% \leavevmode% + \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}}{} +}{}% + + +\ifbool{exsh@beamerwithfootline}{% + \setbeamertemplate{footline}{% + \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 % + !endgroup!end% +> +!global!long!def!exsh@start@skip@Lexercise#1\end{Lexercise}< % + !exsh@dlua % + !ifluatex!else% + !refstepcounter>% + !fi + !endgroup!endgroup% + !expandafter!exsh@skipstuff% + !exsh@dlua% +> +!global!long!def!exsh@start@lframed#1\end{solution}< % + !exsh@dlua % + !endgroup!end% + !exsh@dlua% +> +!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{\pgfkeysvalueof{/exsh/exercise counter}} + 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(kpse.find_file("exsh_lexercise.lua"))} diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index fc7b4d5fdf0..2f6e9f0191e 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -317,7 +317,7 @@ my @TLP_working = qw( exam exam-lite exam-n exam-randomizechoices exam-zh examdesign example examplep examz exceltex excludeonly exercise exercisebank exercisepoints exercises - exesheet exframe exp-testopt + exercisesheets exesheet exframe exp-testopt expdlist expex expex-acro expex-glossonly expkv-bundle export expose-expl3-dunkerque-2019 expressg exsheets exsol extarrows exteps diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 9e841e86596..fddbdf2e5ac 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -491,6 +491,7 @@ depend exercise depend exercisebank depend exercisepoints depend exercises +depend exercisesheets depend exesheet depend exframe depend exp-testopt diff --git a/Master/tlpkg/tlpsrc/exercisesheets.tlpsrc b/Master/tlpkg/tlpsrc/exercisesheets.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3