From 3072f2ccd2f1784315cca4ceabe0c213ea7cb581 Mon Sep 17 00:00:00 2001
From: Frank Fuhlbrück
Date: Thu, 30 Nov 2023 13:35:44 +0100
Subject: v.0.15: solutions headers, sectioning and html compatibility

---
 exercisesheets.sty | 192 +++++++++++++++++++++++++++++++++--------------------
 1 file changed, 121 insertions(+), 71 deletions(-)

(limited to 'exercisesheets.sty')

diff --git a/exercisesheets.sty b/exercisesheets.sty
index 6799a34..733656d 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.14}
-\def\exsh@date{2023/02/06}
+\def\exsh@version{0.15}
+\def\exsh@date{2023/11/30}
 
 \ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
 \message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>}
@@ -48,8 +48,18 @@
 
 % configuration keys
 
-\newif\ifexsh@beamer 
+\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@savetasks
@@ -62,7 +72,7 @@
 %For beamer only
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\ifexsh@beamer 
+\ifexsh@beamer
 \newif\ifexsh@beamerwithheadline
 \newif\ifexsh@beamerwithfootline
 \newif\ifexsh@beameruseblocks
@@ -92,8 +102,8 @@
     beamercompatibility used twice}{}%
 \else
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
-  %currently we do nothing if beamer is loaded, 
+\ifexsh@beamer
+  %currently we do nothing if beamer is loaded,
   %but this might change
 \else%--------- NON-BEAMER: ---------------------------------------
   \let\pause\relax
@@ -168,7 +178,7 @@
 }
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
 \pgfkeys{exsh,
   beamerwithheadline/.is if=exsh@beamerwithheadline,
   beamerwithheadline/.default=true,
@@ -374,7 +384,7 @@
       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}},
@@ -385,6 +395,13 @@
   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},
+  exercise counter/.initial={section},
+  %
   % font specifications
   sheet header font/.initial=\normalfont\normalsize,
   subject font/.initial=\scshape,
@@ -403,6 +420,7 @@
   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,
   %
@@ -440,7 +458,7 @@
 \def\exshset#1{\pgfkeys{exsh,#1}}
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-ONLY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
 \define@key{beamerframe}{t}[true]{% top
   \beamer@frametopskip=-2pt\relax%
   \beamer@framebottomskip=0pt plus 1fill\relax%
@@ -544,7 +562,7 @@
         \OR \exsh@range@entry > \exsh@range@curend\)}{%
         \exsh@isinrangetrue
       }{%
-      }%      
+      }%
     }{%
       \appto{\exsh@range@curend}{#1}%
       \exsh@range@parseend
@@ -555,16 +573,16 @@
 % 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{part}}}%
+  \immediate\write\@auxout{\string\gdef\string\exsh@lastsheet{\arabic{\pgfkeysvalueof{/exsh/sheet counter}}}}%
 }
 
-\numberwithin{page}{part}
+\numberwithin{page}{\pgfkeysvalueof{/exsh/sheet counter}}
 \renewcommand{\thepage}{\arabic{page}}%changed for every sheet
 \setcounter{secnumdepth}{-1}
 
 \AfterPackage*{hyperref}{%
   % make PDF destinations unique:
-  \def\theHsection{\arabic{sheetid}.\arabic{section}}%
+  \def\theHsection{\arabic{sheetid}.\arabic{\pgfkeysvalueof{/exsh/exercise counter}}}%
   \def\theHpage{\arabic{sheetid}-\arabic{page}}%
   %
   % open bookmarks when typesetting a single sheet
@@ -608,18 +626,18 @@
 %   \pgfkeysvalueof{/exsh/sheet start page action}%
   \stepcounter{sheetid}%
   \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/title}}}{%
-    \numdef\exsh@tmp{\value{part}+1}%
+    \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}}%
-    \def\thepage{\arabic{part}-\arabic{page}}%
+    \def\thepage{\arabic{\pgfkeysvalueof{/exsh/sheet counter}}-\arabic{page}}%
   }{%
     \def\thepage{\arabic{page}}%
   }%
   \ifexsh@exnumsheet
-    \edef\exsh@exnumstore{\arabic{section}}
-    \setcounter{section}{0}%
+    \edef\exsh@exnumstore{\arabic{\pgfkeysvalueof{/exsh/exercise counter}}}
+    \setcounter{\pgfkeysvalueof{/exsh/exercise counter}}{0}%
   \fi
-  \numdef\exsh@tmp{\value{part}+1}%
+  \numdef\exsh@tmp{\value{\pgfkeysvalueof{/exsh/sheet counter}}+1}%
   \exsh@checkrange{\exsh@tmp}%
   \ifexsh@isinrange
     \ifexsh@singularrange
@@ -628,7 +646,7 @@
     \fi
     \exsh@sheethead
   \else
-    \refstepcounter{part}%
+    \refstepcounter{\pgfkeysvalueof{/exsh/sheet counter}}%
     \def\exsh@skipwhat{sheet}\expandafter\exsh@skipstuff
   \fi
 }{%
@@ -640,7 +658,7 @@
   \fi
   \endgroup
   \ifexsh@exnumsheet
-    \setcounter{section}{\exsh@exnumstore}%
+    \setcounter{\pgfkeysvalueof{/exsh/exercise counter}}{\exsh@exnumstore}%
   \fi
 }
 \listadd{\exsh@enums}{enumerate}
@@ -661,10 +679,14 @@
 \listadd{\exsh@nonenums}{list}
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
   \let\exsh@hyper@itemtrue\relax
 \else%--------- NON-BEAMER: ---------------------------------------
-  \def\exsh@hyper@itemtrue{\@hyper@itemtrue}
+  \ifexsh@html
+    \let\exsh@hyper@itemtrue\relax%
+  \else
+    \def\exsh@hyper@itemtrue{\@hyper@itemtrue}%
+  \fi
 \fi
 %%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -703,7 +725,7 @@
 \def\exsh@skipstuff@begin#1{%
   \begingroup
   \ifstrequal{#1}{Lexercise}{\exsh@skipstuff@Lexercise}{%
-    \ifstrequal{#1}{exercise}{\refstepcounter{section}%
+    \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}{}{%
@@ -768,7 +790,7 @@
 }
 
 \newcommand{\exsh@skipstuff@incex@@}[2][]{%
-  \refstepcounter{section}
+  \refstepcounter{\pgfkeysvalueof{/exsh/exercise counter}}
   \exsh@autolabel{ex:#2}
   \exsh@skipstuff
 }
@@ -790,14 +812,14 @@
 \let\exsh@skipstuff@incLex@@\exsh@skipstuff@incex@@
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\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{part}%
+  \refstepcounter{\pgfkeysvalueof{/exsh/sheet counter}}%
   \begin{frame}
   \begin{block}{}
     \centering\Large\exsh@tmp
@@ -835,24 +857,43 @@
   \end{frame}
 }
 \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{<span style="float:right">}#1%
+    \exsh@inshtml{</span>}
+  }
+  \global\def\exsh@centering#1{%
+    \exsh@inshtml{<span style="display: block;text-align:center">}#1%
+    \exsh@inshtml{</span>}
+  }
+\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{part}%
-  \part[\pgfkeysvalueof{/exsh/title}]{\normalsize
-    \pgfkeysvalueof{/exsh/sheet header font}\centering%
+  \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}}\hfill
-      {\pgfkeysvalueof{/exsh/semester font}\pgfkeysvalueof{/exsh/semester}}\\
-      {\pgfkeysvalueof{/exsh/author font}\exsh@author}\hfill
-      {\pgfkeysvalueof{/exsh/date font}\pgfkeysvalueof{/exsh/date}}\\
+      {\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
-      \pgfkeysvalueof{/exsh/sheet title font}\exsh@tmp\\\unskip
+      \exsh@centering{\pgfkeysvalueof{/exsh/sheet title font}\exsh@tmp\\}\unskip
     \endgroup
     \begingroup
       \pgfkeysvalueof{/exsh/sheet header font}%
@@ -861,7 +902,7 @@
           \begingroup
             \pgfkeysvalueof{/exsh/solutionsby font}%
             \vskip\pgfkeysvalueof{/exsh/above solutionsby skip}\relax
-            \pgfkeysvalueof{/exsh/strings/solutionsby}~\exsh@solutionsby\\\unskip%
+            \exsh@centering{\pgfkeysvalueof{/exsh/strings/solutionsby}~\exsh@solutionsby\\}\unskip%
           \endgroup
         }%
       \else
@@ -872,7 +913,7 @@
           \begingroup
             \pgfkeysvalueof{/exsh/sheet note font}%
             \vskip\pgfkeysvalueof{/exsh/above sheet note skip}\relax
-            \pgfkeysvalueof{/exsh/note}\\\unskip%
+            \exsh@centering{\pgfkeysvalueof{/exsh/note}\\}\unskip%
           \endgroup
         }%
       }%
@@ -904,13 +945,13 @@
   %\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{section}+1\endcsname
+    \ifcsname exsh@sumpts@\the\numexpr\arabic{\pgfkeysvalueof{/exsh/exercise counter}}+1\endcsname
       \edef\exsh@sumpts{%
-        \csname exsh@sumpts@\the\numexpr\arabic{section}+1%
+        \csname exsh@sumpts@\the\numexpr\arabic{\pgfkeysvalueof{/exsh/exercise counter}}+1%
         \endcsname%
       }%
       \edef\exsh@sumptsbonus{%
-        \csname exsh@sumptsbonus@\the\numexpr\arabic{section}+1%
+        \csname exsh@sumptsbonus@\the\numexpr\arabic{\pgfkeysvalueof{/exsh/exercise counter}}+1%
         \endcsname%
       }%
       \ifnumequal{\exsh@sumpts}{0}{%
@@ -978,9 +1019,14 @@
     }{%
       \edef\exsh@shortpoints{ (\expandonce\exsh@points)}%
     }%
-    \preto\exsh@points{\enskip\hfill\bgroup%
-      \pgfkeysvalueof{/exsh/points font}}%
-    \appto\exsh@points{\egroup}%
+%     \preto\exsh@points{
+%       \exsh@inshtml{<span style="float:right">}\hfill
+%       \enskip\exsh@alignright\bgroup%
+%       \pgfkeysvalueof{/exsh/points font}}%
+%     \appto\exsh@points{\egroup\exsh@inshtml{</span>}}%
+    \edef\exsh@points{\exsh@alignright{%
+      \pgfkeysvalueof{/exsh/points font}\expandonce\exsh@points
+    }}
   }%
   \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/firstline}}}{%
     \def\exsh@firstline{}%
@@ -996,15 +1042,15 @@
     \edef\exsh@exname{\space(\pgfkeysvalueof{/exsh/name})}%
     \edef\exsh@shortexname{:\space\pgfkeysvalueof{/exsh/name}}%
   }%
-  \refstepcounter{section}%
-  \edef\exsh@tmp{[\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}\exsh@shortexname\expandonce\exsh@shortpoints]}%
+  \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@startsection\exsh@tmp{\noindent%
       \hbox to 0pt{\hss\pgfkeysvalueof{/exsh/exercisemark}}%
-      \pgfkeysvalueof{/exsh/strings/exercise}~\arabic{section}\exsh@exname\exsh@firstline\expandonce\exsh@points}%
+      \pgfkeysvalueof{/exsh/strings/exercise}~\arabic{\pgfkeysvalueof{/exsh/exercise counter}}\exsh@exname\exsh@firstline\expandonce\exsh@points}%
     \unskip\vskip\pgfkeysvalueof{/exsh/below exercise title skip}\relax
     \@afterindentfalse
     % automatic label for the first exercise in every included file
@@ -1021,11 +1067,11 @@
   \ifexsh@sumuppoints%
     \immediate\write\@auxout{
       \string\expandafter\gdef%
-      \detokenize{\csname} exsh@sumpts@\arabic{section}\endcsname{%
+      \detokenize{\csname} exsh@sumpts@\arabic{\pgfkeysvalueof{/exsh/exercise counter}}\endcsname{%
         \arabic{exsh@pts@cur}%
       }%
       \string\expandafter\gdef%
-      \detokenize{\csname} exsh@sumptsbonus@\arabic{section}\endcsname{%
+      \detokenize{\csname} exsh@sumptsbonus@\arabic{\pgfkeysvalueof{/exsh/exercise counter}}\endcsname{%
         \arabic{exsh@ptsbonus@cur}%
       }%
     }%
@@ -1035,7 +1081,7 @@
 \newcommand{\exsh@label}[2]{#1{#2}\leavevmode\ignorespaces}
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
 \newcommand{\exsh@startsection}[2][]{%
    \newpage
 %   \begin{block}{}
@@ -1069,7 +1115,7 @@
 }%
 \else%--------- NON-BEAMER: ---------------------------------------
 \newcommand{\exsh@startsection}[2][]{%
-  \@startsection{section}{1}{\z@}%
+  \@startsection{\pgfkeysvalueof{/exsh/exercise counter}}{1}{\z@}%
   {\pgfkeysvalueof{/exsh/above exercise skip}}%
   {1em}% afterskip corrected below
   {\pgfkeysvalueof{/exsh/exercise title font}}%
@@ -1160,7 +1206,7 @@
 }
 \else
   \newcommand{\exsh@includeLexercise}[2][]{
-    \refstepcounter{section}
+    \refstepcounter{\pgfkeysvalueof{/exsh/exercise counter}}
     Lexercise needs Lua\LaTeX!
   }
   \let\exsh@includeLexercise@\exsh@includeLexercise
@@ -1175,7 +1221,7 @@
 
 \ifexsh@patchenumerate
   \AfterPackage*{varioref}{
-    \labelformat{enumi}{\arabic{section}.\alph{enumi}}
+    \labelformat{enumi}{\arabic{\pgfkeysvalueof{/exsh/exercise counter}}.\alph{enumi}}
     \def\exsh@afterdot#1.#2{#2}%x.y -> y
     \def\exsh@subexn#1{%
       \if\getrefnumber{#1}0%
@@ -1197,12 +1243,12 @@
     \setenumerate[3]{label=\roman*.}
     \setenumerate[4]{label=\Alph.}
   }
-  \def\theHenumi{enumi.\arabic{part}.\arabic{section}.\arabic{enumi}}
+  \def\theHenumi{enumi.\arabic{\pgfkeysvalueof{/exsh/sheet counter}}.\arabic{\pgfkeysvalueof{/exsh/exercise counter}}.\arabic{enumi}}
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
   % code below breaks [] argument after \begin{enumerate}
   % when beamer is used
-  % in beamer we set item labels separately 
+  % in beamer we set item labels separately
   % see beamer specific def. of \exsh@startsection
 \else%--------- NON-BEAMER: ---------------------------------------
   \AtEndPreamble{%
@@ -1246,7 +1292,7 @@
   \csname cl@\exsh@subtaskctr\endcsname
 
 % reset equation numbering for each exercise
-\@addtoreset{equation}{section}
+\@addtoreset{equation}{\pgfkeysvalueof{/exsh/exercise counter}}
 
 \long\def\exsh@savemaintask#1{%
   \global\def\exsh@restatetaskmain{#1}%
@@ -1306,7 +1352,7 @@
 }
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
   \let\restatetaskbeamer\restatetask
 \else%--------- NON-BEAMER: ---------------------------------------
   \def\restatetaskbeamer{%
@@ -1333,7 +1379,7 @@
 
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
   \let\exsh@postsolutionclear\clearpage
 \else%--------- NON-BEAMER: ---------------------------------------
   \let\exsh@postsolutionclear\par
@@ -1377,13 +1423,13 @@
 
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\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{section}%
+      (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{\pgfkeysvalueof{/exsh/exercise counter}}%
         \ifnum\@enumdepth>0\alph{subex}\fi)} %
         \ifbool{exsh@headerrestate}{
           \exsh@ensuresavetasks
@@ -1397,7 +1443,7 @@
         {block title alerted}
       {\pgfkeysvalueof{/exsh/solution title font}%
       \pgfkeysvalueof{/exsh/strings/solution} %
-      (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
+      (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{\pgfkeysvalueof{/exsh/exercise counter}}%
         \ifnum\@enumdepth>0\alph{subex}\fi)} %
       \ifbool{exsh@headerrestate}{
         \exsh@ensuresavetasks
@@ -1437,14 +1483,14 @@
 
 \else%--------- NON-BEAMER: ---------------------------------------
 %this command is only usefule for exercisesheets-beamer to place
-%the deferred title within a new frame 
+%the deferred title within a new frame
 \newcommand{\solutiontitle}[1][]{}
 \fi
 %%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
 \def\exsh@startsolution{%
   \ifnum\@enumdepth=0
     \clearpage
@@ -1454,7 +1500,7 @@
 %   \block{}
 %     \pgfkeysvalueof{/exsh/solution title font}%
 %     \pgfkeysvalueof{/exsh/strings/solution} %
-%     (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{section}%
+%     (\pgfkeysvalueof{/exsh/strings/exercise} \arabic{\pgfkeysvalueof{/exsh/exercise counter}}%
 %     \alph{subex})%
 %   \endblock
   \ifbool{exsh@framed}{\exsh@defersolutiontitletrue}{}
@@ -1481,7 +1527,9 @@
   \vskip\pgfkeysvalueof{/exsh/above solution skip}\relax%
   {\parindent \z@
     \pgfkeysvalueof{/exsh/solution title font}%
-    \pgfkeysvalueof{/exsh/strings/solution}:\par}\nobreak%
+    \pgfkeysvalueof{/exsh/strings/solution}%
+    \pgfkeysvalueof{/exsh/solution title separator}%
+  }\nobreak%
   \@afterheading
 }%
 \fi
@@ -1502,7 +1550,7 @@
 }
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
 \newenvironment<>{beamersolution}[1][]{%
   \pgfkeys{exsh,every solution,#1,solution font}%
   \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
@@ -1675,7 +1723,7 @@
 
 
 %%%%%%%%%%%%%%% BEGIN BEAMER-ONLY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifexsh@beamer 
+\ifexsh@beamer
 \setbeamertemplate{headline}{%
 % \leavevmode%
   \ifbool{exsh@beamerwithheadline}{%
@@ -1726,12 +1774,12 @@
   \def\exsh@dlua#1{}
 \fi
 
-%change only some catcodes to 
+%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 %set those to the same value (11/12) as below!
 \catcode`\}=12 %
 \catcode`<=1
 \catcode`>=2
@@ -1744,7 +1792,9 @@
 >
 !global!long!def!exsh@start@skip@Lexercise#1\end{Lexercise}< %
   !exsh@dlua<exsh_cur_exercise=exercise({#1})> %
-  !ifluatex!else!refstepcounter<section>!fi
+  !ifluatex!else%
+    !refstepcounter<!pgfkeysvalueof</exsh/exercise counter>>%
+  !fi
   !endgroup!endgroup%
   !expandafter!exsh@skipstuff%
     !exsh@dlua<exsh_texprintlines(exsh_cur_exercise)>%
@@ -1765,7 +1815,7 @@
 \catcode`\^=12
 \catcode`\&=12
 \catcode`\|=12
-\catcode`\{=12 %set those to the same value (11/12) as above! 
+\catcode`\{=12 %set those to the same value (11/12) as above!
 \catcode`\}=12 %
 \catcode`\~=12
 \catcode`\@=11
@@ -1781,7 +1831,7 @@
   \ifluatex
     \exsh@dlua{exsh_texprintlines(exsh_cur_exercise)}%
   \else
-    \refstepcounter{section}
+    \refstepcounter{\pgfkeysvalueof{/exsh/exercise counter}}
     Lexercise needs Lua\LaTeX!
   \fi
 }
-- 
cgit v1.2.3

