From 392ef991c763e22a148b0b8bd344c18c42b94069 Mon Sep 17 00:00:00 2001 From: Frank Fuhlbrück Date: Wed, 19 Jan 2022 16:29:14 +0100 Subject: task evironments (NOT finished) --- README | 1 + examples/exshexample.tex | 80 +++++++++++++++++++++++++++++++++++++++++++++++- exercisesheets.sty | 54 +++++++++++++++++++++++++++++++- exercisesheets.tex | 3 +- 4 files changed, 135 insertions(+), 3 deletions(-) diff --git a/README b/README index b050f36..dd02b18 100644 --- a/README +++ b/README @@ -13,3 +13,4 @@ exercisesheets.sty The package itself exercisesheets.tex Documentation source exercisesheets.el Emacs integration (outdated) README This file +Examples Folder with example file diff --git a/examples/exshexample.tex b/examples/exshexample.tex index 762b386..6a0d4f2 100644 --- a/examples/exshexample.tex +++ b/examples/exshexample.tex @@ -1,11 +1,19 @@ \long\def\ifbeamer#1#2{#2} \ifbeamer{\documentclass{beamer}}{\documentclass{article}} +%navigation symbols and the title collide if +%beamerwithheadline is set +\ifbeamer{ + \setbeamertemplate{navigation symbols}{} +}{} + %patchenumerate is the deafault -\usepackage[patchenumerate=true]% +\usepackage[patchenumerate=true,beamerwithheadline, + beamercompatibility]% {exercisesheets\ifbeamer{-beamer}{}} \usepackage{varioref} \usepackage{hyperref} +\usepackage{xcolor} \begin{document} @@ -25,6 +33,10 @@ } } + +\exshset{solutions=true, +task restate font={\color{black!60}}} + \begin{sheet}[note={Learn how to create nice exercise sheets.}, date={Novanuar 42, -2022},title={First Sheet}] @@ -60,6 +72,9 @@ number within sheet] \begin{exercise}[points={many, many}, firstline={Read the manual.}] + \begin{solution} + OK, done. + \end{solution} \end{exercise} \end{sheet} @@ -67,10 +82,73 @@ \begin{exercise}[points={many, many}, firstline={Read the manual.}] Observe how a sheet with title restarts the exercise numbering. + \begin{solution}[framed] + OK, done (again). + \newframe + Otherwise, I would'nt now now \textbackslash newframe 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}? + + \begin{exercise}[points={many, many}, + firstline={Play around with the options.}] + Observe how a sheet with title restarts the exercise numbering. + \begin{solution}[defersolutiontitle] + \begin{frame} + This is a dual-use solution with explicit + beamer frames (and no framed). + \solutiontitle + Note, that we can freely place the title, because of + defersolutiontitle. + \end{frame} + \end{solution} + \end{exercise} + + \begin{exercise}[points={many, many},beamersolution, + firstline={Play around with the options.}] + Observe how a sheet with title restarts the exercise numbering. + \begin{solution} + This solution is only shown if using the non-beamer version, because the option beamersolution was used. Otherwise both + solutions would be shown. You can set + the option beamersolution for individual (normal) solutions + to ignore some but not all solutions of an exercise. + \end{solution} + \begin{beamersolution}[defersolutiontitle] + \begin{frame}[t] + \solutiontitle + This beamersolution is only shown if using the beamer + version. + \end{frame} + \end{beamersolution} + \end{exercise} + + \begin{frame} + \begin{exercise}[points={many, many}] + \visible<1>{Be careful using only etc.} + \visible<2>{The overlay specification is simply + ignored.} + \visible<3>{So all content is visible simultaneously and + should not contradict or break itself.} + \end{exercise} + \end{frame} + + \begin{exercise}[points={many, many}] + \begin{maintask}[savetasks] + The exercise task can be saved and restated. + \end{maintask} + \begin{subtasks}[savetasks] + \item first + \begin{solution} + None (yet). + \end{solution} + \item second + \end{subtasks} + I forgot all the tasks! + \restatetask + \end{exercise} \end{sheet} diff --git a/exercisesheets.sty b/exercisesheets.sty index 2d8298d..9da1f41 100644 --- a/exercisesheets.sty +++ b/exercisesheets.sty @@ -18,7 +18,7 @@ %\NeedsTeXFormat{LaTeX2e}[1994/12/01] % don't forget to update the version and date in exercisesheets.tex -\def\exsh@version{0.10} +\def\exsh@version{0.10+git} \def\exsh@date{2022/01/12} \ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets] @@ -29,6 +29,7 @@ \RequirePackage{etoolbox}%[2008/06/28] \RequirePackage{scrlfile} +\RequirePackage{environ} \RequirePackage{pgfkeys} \RequirePackage{keyval} @@ -45,6 +46,7 @@ % configuration keys \newif\ifexsh@patchenumerate\exsh@patchenumeratetrue +\newif\ifexsh@savetasks \newif\ifexsh@solutions \newif\ifexsh@oralsolutions \newif\ifexsh@nonoralsolutions @@ -68,6 +70,7 @@ \PackageError{exercisesheets}{ beamercompatibility used twice}{}% \else + %TODO:\only<>{A} -> {A} which breaks global effects of A \let\pause\relax \def\frame{} \renewcommand{\frame}[1][]{} @@ -96,6 +99,8 @@ \pgfkeys{/exsh/.is family,/exsh, patchenumerate/.is if=exsh@patchenumerate, patchenumerate/.default=true, + savetasks/.is if=exsh@savetasks, + savetasks/.default=true, solutions/.is choice, solutions/true/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionstrue, solutions/oral/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionsfalse, @@ -225,6 +230,7 @@ optional/.value forbidden, exercisemark/.initial={}, difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden, + savetasks/.initial=false, % % translatable strings strings/sheet/.initial={}, @@ -322,6 +328,9 @@ sheet title font/.initial=\Large\bfseries, exercise title font/.initial=\bfseries, points font/.initial=\itshape, + main task font/.initial={}, + subtasks font/.initial={}, + task restate font/.initial=\itshape, hint font/.initial={}, hint title font/.initial=\itshape, solution font/.initial={}, @@ -928,6 +937,49 @@ % reset equation numbering for each exercise \@addtoreset{equation}{section} +\long\def\exsh@savemaintask#1{% + \global\def\exsh@restatetaskmain{#1}% + #1% +} + +\newenvironment{maintask}[1][]{% + \pgfkeys{exsh,#1}% + \pgfkeysvalueof{/exsh/main task font}% + \ifbool{exsh@savetasks}{\Collect@Body\exsh@savemaintask}{}% + \ignorespaces +}{} + +%we ignore everything before the frist item +%and process everything afterwards +\long\def\exsh@processsubtasks#1\item#2\item{% +\ifstrequal{#2}{}{}{% +\item #2% +\exsh@processsubtasks\item%new "frist" \item to ignore +}%no whitespace here is crucial for end detecttion +} + +\long\def\exsh@collectedsubtasks#1{ +\begin{enumerate} +\exsh@processsubtasks#1\item\item +\end{enumerate}% +} + +\newenvironment{subtasks}[1][]{% + \pgfkeys{exsh,#1}% + \pgfkeysvalueof{/exsh/subtasks font}% + \ifbool{exsh@savetasks}{\Collect@Body\exsh@collectedsubtasks}{ + \begin{enumerate} + }% + \ignorespaces +}{ + \ifbool{exsh@savetasks}{}{\end{enumerate}} +} + +\newcommand{\restatetask}[1][main]{ + {\pgfkeysvalueof{/exsh/task restate font}% + \csname exsh@restatetask#1\endcsname} +} + \newenvironment{hint}[1][]{% \par \pgfkeys{exsh,every hint,#1,hint font}% diff --git a/exercisesheets.tex b/exercisesheets.tex index a8bf2ff..1ea33ea 100644 --- a/exercisesheets.tex +++ b/exercisesheets.tex @@ -300,7 +300,8 @@ The following \param{options} are supported: head. By default, the value passed to \verb|\subject| is used. \item[\option{semester=\param{semester}}] Set the semester included in the sheet head. By default, the value passed to \verb|\date| is used. - \item[\option{beamerwithheadline\opt{=\param{true/false}}}] Controls wether a headline with author, subject etc. is shown on beamer slides. + \item[\option{beamerwithheadline\opt{=\param{true/false}}}] Controls wether 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. \end{description} -- cgit v1.2.3