aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Fuhlbrück2022-01-21 18:01:24 +0100
committerFrank Fuhlbrück2022-01-21 18:01:24 +0100
commit0f1e5c6c1712957a86654177d55175aaf7cd2f8e (patch)
tree63120bd2ac9ef3055d2865898d72e329e8835279
parent392ef991c763e22a148b0b8bd344c18c42b94069 (diff)
downloadexercisesheets-0f1e5c6c1712957a86654177d55175aaf7cd2f8e.tar.gz
exercisesheets-0f1e5c6c1712957a86654177d55175aaf7cd2f8e.tar.bz2
exercisesheets-0f1e5c6c1712957a86654177d55175aaf7cd2f8e.zip
environments for main task and subtasks
-rw-r--r--examples/exshexample.tex18
-rw-r--r--exercisesheets-beamer.sty64
-rw-r--r--exercisesheets.sty30
3 files changed, 95 insertions, 17 deletions
diff --git a/examples/exshexample.tex b/examples/exshexample.tex
index 6a0d4f2..f7782e0 100644
--- a/examples/exshexample.tex
+++ b/examples/exshexample.tex
@@ -1,4 +1,4 @@
-\long\def\ifbeamer#1#2{#2}
+\long\def\ifbeamer#1#2{#1}
\ifbeamer{\documentclass{beamer}}{\documentclass{article}}
%navigation symbols and the title collide if
@@ -35,7 +35,8 @@
\exshset{solutions=true,
-task restate font={\color{black!60}}}
+task restate font={\color{black!60}},
+}
\begin{sheet}[note={Learn how to create nice exercise sheets.},
date={Novanuar 42, -2022},title={First Sheet}]
@@ -135,19 +136,22 @@ task restate font={\color{black!60}}}
\end{exercise}
\end{frame}
- \begin{exercise}[points={many, many}]
- \begin{maintask}[savetasks]
+ \begin{exercise}[points={many, many},savetasks,
+ main task font={\scshape},subtask font={\itshape}
+ ]
+ \begin{maintask}
The exercise task can be saved and restated.
\end{maintask}
- \begin{subtasks}[savetasks]
- \item first
+ \begin{subtasks}
+ \subtask{first}
\begin{solution}
None (yet).
\end{solution}
- \item second
+ \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}
\end{sheet}
diff --git a/exercisesheets-beamer.sty b/exercisesheets-beamer.sty
index 5ac11f4..1cc949e 100644
--- a/exercisesheets-beamer.sty
+++ b/exercisesheets-beamer.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-Beamer}
+\def\exsh@version{0.10+}
\def\exsh@date{2022/01/12}
\ProvidesPackage{exercisesheets-beamer}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
@@ -46,6 +46,7 @@
% configuration keys
\newif\ifexsh@patchenumerate\exsh@patchenumeratetrue
+\newif\ifexsh@savetasks
\newif\ifexsh@solutions
\newif\ifexsh@oralsolutions
\newif\ifexsh@nonoralsolutions
@@ -80,6 +81,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,
@@ -212,6 +215,7 @@
optional/.value forbidden,
exercisemark/.initial={},
difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden,
+ savetasks/.initial=false,
%
% translatable strings
strings/sheet/.initial={},
@@ -309,6 +313,9 @@
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={},
@@ -929,6 +936,61 @@
% 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%
+\csgdef{exsh@restatetask\arabic{enumi}}{#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}%
+}
+
+\def\exsh@subtaskenv{enumerate}
+\def\exsh@subtaskitm{item}
+\def\exsh@subtaskctr{enumi}
+\newenvironment{subtasks}[1][]{%
+ \pgfkeys{exsh,#1}%
+ \begin{\exsh@subtaskenv}
+ \ignorespaces
+}{
+ \end{\exsh@subtaskenv}%
+}
+
+\newcommand{\subtask}[2][]{%
+ \begingroup
+ \pgfkeys{exsh,#1}%
+ \csname\exsh@subtaskitm\endcsname%
+ {\pgfkeysvalueof{/exsh/subtask font} #2}%
+ \ifbool{exsh@savetasks}{%
+ \csgdef{exsh@restatetask\arabic{\exsh@subtaskctr}}{#2}%
+ }{}%
+ \endgroup
+}
+
+\newcommand{\restatetask}[1][main]{%
+ {\pgfkeysvalueof{/exsh/task restate font}%
+ \csname exsh@restatetask#1\endcsname}%
+}
+
\newenvironment{hint}[1][]{%
\par
\pgfkeys{exsh,every hint,#1,hint font}%
diff --git a/exercisesheets.sty b/exercisesheets.sty
index 9da1f41..fd0f574 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -1,5 +1,5 @@
%% exercisesheets.sty
-%% Copyright 2008-2017 Sebastian Kuhnert, Frank Fuhlbrück
+%% Copyright 2008-2022 Sebastian Kuhnert, Frank Fuhlbrück
%
% This work may be distributed and/or modified under the conditions
% of the LaTeX Project Public License, either version 1.3c of this
@@ -329,7 +329,7 @@
exercise title font/.initial=\bfseries,
points font/.initial=\itshape,
main task font/.initial={},
- subtasks font/.initial={},
+ subtask font/.initial={},
task restate font/.initial=\itshape,
hint font/.initial={},
hint title font/.initial=\itshape,
@@ -954,6 +954,7 @@
\long\def\exsh@processsubtasks#1\item#2\item{%
\ifstrequal{#2}{}{}{%
\item #2%
+\csgdef{exsh@restatetask\arabic{enumi}}{#2}%
\exsh@processsubtasks\item%new "frist" \item to ignore
}%no whitespace here is crucial for end detecttion
}
@@ -964,20 +965,31 @@
\end{enumerate}%
}
+\def\exsh@subtaskenv{enumerate}
+\def\exsh@subtaskitm{item}
+\def\exsh@subtaskctr{enumi}
\newenvironment{subtasks}[1][]{%
\pgfkeys{exsh,#1}%
- \pgfkeysvalueof{/exsh/subtasks font}%
- \ifbool{exsh@savetasks}{\Collect@Body\exsh@collectedsubtasks}{
- \begin{enumerate}
- }%
+ \begin{\exsh@subtaskenv}
\ignorespaces
}{
- \ifbool{exsh@savetasks}{}{\end{enumerate}}
+ \end{\exsh@subtaskenv}%
+}
+
+\newcommand{\subtask}[2][]{%
+ \begingroup
+ \pgfkeys{exsh,#1}%
+ \csname\exsh@subtaskitm\endcsname%
+ {\pgfkeysvalueof{/exsh/subtask font} #2}%
+ \ifbool{exsh@savetasks}{%
+ \csgdef{exsh@restatetask\arabic{\exsh@subtaskctr}}{#2}%
+ }{}%
+ \endgroup
}
-\newcommand{\restatetask}[1][main]{
+\newcommand{\restatetask}[1][main]{%
{\pgfkeysvalueof{/exsh/task restate font}%
- \csname exsh@restatetask#1\endcsname}
+ \csname exsh@restatetask#1\endcsname}%
}
\newenvironment{hint}[1][]{%