From 79977e2d85e6aca37c9dd58b219d198d42ce6f4c Mon Sep 17 00:00:00 2001
From: Frank Fuhlbrück
Date: Mon, 6 Feb 2023 15:48:33 +0100
Subject: v0.14: option headerrestate

---
 exercisesheets.sty | 42 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)

(limited to 'exercisesheets.sty')

diff --git a/exercisesheets.sty b/exercisesheets.sty
index 006d9ed..6799a34 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -1,5 +1,5 @@
 %% exercisesheets.sty
-%% Copyright 2008-2022 Sebastian Kuhnert, Frank Fuhlbrück
+%% 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
@@ -18,8 +18,8 @@
 %\NeedsTeXFormat{LaTeX2e}[1994/12/01]
 
 % don't forget to update the version and date in exercisesheets.tex
-\def\exsh@version{0.13.1}
-\def\exsh@date{2022/11/22}
+\def\exsh@version{0.14}
+\def\exsh@date{2023/02/06}
 
 \ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
 \message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>}
@@ -67,6 +67,7 @@
 \newif\ifexsh@beamerwithfootline
 \newif\ifexsh@beameruseblocks
 \newif\ifexsh@defersolutiontitle
+\newif\ifexsh@headerrestate
 \newif\ifexsh@framed
 \newif\ifexsh@fragile
 \fi
@@ -179,6 +180,8 @@
   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,
@@ -188,6 +191,7 @@
   beamerwithfootline/.initial={false},
   beameruseblocks/.initial={false},
   defersolutiontitle/.initial={false},
+  headerrestate/.initial={false},
   framed/.initial={false},
 }
 \else%--------- NON-BEAMER: ---------------------------------------
@@ -200,6 +204,8 @@
   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},
@@ -1275,7 +1281,17 @@
   }{}%
 }
 
+\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%
 }
 
@@ -1365,18 +1381,30 @@
 \def\exsh@solutiontitle#1{
   \ifbool{exsh@beameruseblocks}{%
     \begin{alertblock}{}%
-    \pgfkeysvalueof{/exsh/solution title font}%
+    {\pgfkeysvalueof{/exsh/solution title font}%
       \pgfkeysvalueof{/exsh/strings/solution} %
       (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
-        \ifnum\@enumdepth>0\alph{subex}\fi)%
+        \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/solution title font}%
       \pgfkeysvalueof{/exsh/strings/solution} %
       (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
-        \ifnum\@enumdepth>0\alph{subex}\fi)%
+        \ifnum\@enumdepth>0\alph{subex}\fi)} %
+      \ifbool{exsh@headerrestate}{
+        \exsh@ensuresavetasks
+        \csname exsh@restatetask%
+        \ifnum\@enumdepth>0cur\else main\fi%
+        \endcsname%
+      }{}%
     \end{beamercolorbox}
   }
 }
-- 
cgit v1.2.3

