From 026c602a4aa6f2b6eeca3bcbdd714425e07ad829 Mon Sep 17 00:00:00 2001
From: Frank Fuhlbrück
Date: Wed, 24 Apr 2024 11:31:24 +0200
Subject: v.0.17: fix bugs with embedded+beamer; better documenation

---
 exercisesheets.sty | 54 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 16 deletions(-)

(limited to 'exercisesheets.sty')

diff --git a/exercisesheets.sty b/exercisesheets.sty
index 403dc1f..34a68ce 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -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.16}
-\def\exsh@date{2024/03/07}
+\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>}
@@ -64,6 +64,7 @@
 \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}
@@ -151,6 +152,7 @@
     \exsh@patchenumeratefalse
     \exsh@settitlefalse
     \exsh@patchpagenumbersfalse
+    \exsh@patchheadandfootfalse
     \exsh@usestartsectionfalse
     \pgfkeysalso{secnumdepth=keep}%
     \def\exhs@sheetnoheader[##1]##2{}%
@@ -670,6 +672,8 @@
     \title{\exsh@title}
   \fi
 }
+\else
+  \def\exsh@write@title#1{}
 \fi
 
 \newcounter{sheetid}% only used to disambiguate hyperref labels
@@ -1153,6 +1157,7 @@
 \ifexsh@beamer
 \newcommand{\exsh@startheader}[2][]{%
    \newpage
+   \stepcounter{framenumber}
 %   \begin{block}{}
 %   \pgfkeysvalueof{/exsh/exercise title font}{#2}%
 %   \end{block}
@@ -1405,15 +1410,28 @@
 \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][]{%
-  \endgroup
-  \begingroup
+  \exsh@ensuressubtasks
   \pgfkeys{exsh,#1}%
   \csname\exsh@subtaskitm\endcsname%
     {\pgfkeysvalueof{/exsh/subtask font} #2}%
@@ -1590,7 +1608,7 @@
 \ifexsh@beamer
 \def\exsh@startsolution{%
   \ifnum\@enumdepth=0
-    \clearpage
+    \ifbool{exsh@framed}{}{\clearpage\stepcounter{framenumber}}
   \fi
 %   \usebeamercolor{block title alerted}
 %   \setbeamercolor{block body}{bg=bg,fg=fg}
@@ -1821,9 +1839,13 @@
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-ONLY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \ifexsh@beamer
-\setbeamertemplate{headline}{%
-% \leavevmode%
-  \ifbool{exsh@beamerwithheadline}{%
+\ifexsh@patchheadandfoot
+  \setbeamertemplate{headline}{}%
+  \setbeamertemplate{footline}{}%
+\fi
+\ifbool{exsh@beamerwithheadline}{%
+  \setbeamertemplate{headline}{%
+%     \leavevmode%
     \begin{beamercolorbox}[wd=\paperwidth,vmode]{frametitle}
       \vspace{0.4em}
       \leavevmode
@@ -1843,13 +1865,13 @@
     \end{beamercolorbox}%
     \vspace*{3mm}
     \vskip\pgfkeysvalueof{/exsh/below slide headline skip}\relax%
-  }{}%
-}
-\addtobeamertemplate{frametitle}{\vspace{-3mm}}{}
+  }
+  \addtobeamertemplate{frametitle}{\vspace{-3mm}}{}
+}{}%
 
-\setbeamertemplate{footline}
-{%
-  \ifbool{exsh@beamerwithfootline}{%
+
+\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}}
@@ -1860,8 +1882,8 @@
       \hfill\insertpagenumber
     \end{beamercolorbox}}%
     \vskip0pt%
-  }{}%
-}
+  }
+}{}%
 \fi
 %%%%%%%%%%%%%%% END BEAMER-ONLY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-- 
cgit v1.2.3

