aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Fuhlbrück2023-11-30 13:35:44 +0100
committerFrank Fuhlbrück2023-11-30 13:35:44 +0100
commit3072f2ccd2f1784315cca4ceabe0c213ea7cb581 (patch)
treed93932d9d00e352a465c37d41e7943115e110ed1
parent79977e2d85e6aca37c9dd58b219d198d42ce6f4c (diff)
downloadexercisesheets-3072f2ccd2f1784315cca4ceabe0c213ea7cb581.tar.gz
exercisesheets-3072f2ccd2f1784315cca4ceabe0c213ea7cb581.tar.bz2
exercisesheets-3072f2ccd2f1784315cca4ceabe0c213ea7cb581.zip
v.0.15: solutions headers, sectioning and html compatibility0.15
-rw-r--r--exercisesheets.sty192
-rw-r--r--exercisesheets.tex198
2 files changed, 250 insertions, 140 deletions
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
}
diff --git a/exercisesheets.tex b/exercisesheets.tex
index c41250f..68636f9 100644
--- a/exercisesheets.tex
+++ b/exercisesheets.tex
@@ -53,7 +53,7 @@
\usepackage[english,iso]{isodate}
\title{The \exsh Package}
\author{Sebastian Kuhnert\and Frank Fuhlbrück}
-\date{Version 0.14, \printdateTeX{2023/02/06}}
+\date{Version 0.15, \printdateTeX{2023/11/30}}
\begin{document}
\maketitle
@@ -64,10 +64,10 @@ finally combined into this package. Starting from Version 0.7, there was an alte
\subsection*{Licence}
-Copyright \textcopyright{} 2008--2022 Sebastian Kuhnert and Frank Fuhlbrück.
+Copyright \textcopyright{} 2008--2023 Sebastian Kuhnert and Frank Fuhlbrück.
Permission is granted to copy, distribute and/or modify this software under the
terms of the \LaTeX{} Project Public Licence, version 1.3c or later. This
-package is maintained, the Current Maintainer is
+package is maintained, the Current Maintainer is
Frank Fuhlbrück
\footnote{\href{mailto:frank@fuhlbrueck.net}{frank@fuhlbrueck.net}}.
@@ -174,32 +174,32 @@ The following options are available:
\item[\option{pointsfloatright}] Use an alternative mechanism to place points for Sub-Exercises.
If this option is used, the points label for a Sub-Exercise is placed at the (right) end of the current line.
It is especially useful if used in a context like \texttt{$\backslash$item$\backslash$points$\{3\}$}.
- This option exploits (and partially breaks) RTL-Support.
- \item[\option{exercisespath}] Set the (relative) path of the
- directory containing exercises to be included via
+ This option exploits (and partially breaks) RTL-Support.
+ \item[\option{exercisespath}] Set the (relative) path of the
+ directory containing exercises to be included via
\verb|\includeexercise|.
\item[\option{patchenumerate}\opt{=\param{true/false}}] Sets
enumerate item labels for the first four levels, starting with
- a), b) etc. for the top-level (sub-exercises). Depending on other
+ a), b) etc. for the top-level (sub-exercises). Depending on other
loaded packages (\verb|enumitem|, \verb|paralist|) the mechanism
slightly differs. This option is active by default.
-
- \item[\option{showtodos} / \option{hidetodos}]
+
+ \item[\option{showtodos} / \option{hidetodos}]
\verb|\TODO| markers
- are hidden by default, this option switches their behavior. This
- option is usually set within \verb|\ifsamplesolutions| or
+ are hidden by default, this option switches their behavior. This
+ option is usually set within \verb|\ifsamplesolutions| or
similar.
- \item[\option{beamercompatibility}\opt{=\param{true/false}}]
+ \item[\option{beamercompatibility}\opt{=\param{true/false}}]
This options (which only is effective in the non-beamer version)
- defines several beamer macros with as trivial
+ defines several beamer macros with as trivial
effects as possible, e.g., \verb|\pause| becomes \verb|\relax|
- and overlay specifications are mostly ignored. Be careful to use
- this option after loading \verb|enumitem| etc. as the enumerate
- and itemize environment are defined to swallow overlay
+ and overlay specifications are mostly ignored. Be careful to use
+ this option after loading \verb|enumitem| etc. as the enumerate
+ and itemize environment are defined to swallow overlay
specifications without effect, this also holds for
\verb|\item<1->|. If you load \verb|exercisesheets| before them
use \verb|\exshset| afterwards.
- The current list of redefinitions is as
+ The current list of redefinitions is as
follows:
\begin{lstlisting}
\let\pause\relax
@@ -225,11 +225,11 @@ The following options are available:
\@ifnextchar[\exsh@ovrlenumerate\exsh@origenumerate}
\end{lstlisting}
-\item[\option{filenameasexercisename}\opt{=\param{true/false}}]
-This option (set to false by default) causes
+\item[\option{filenameasexercisename}\opt{=\param{true/false}}]
+This option (set to false by default) causes
\verb|\includeexercise| to
set the name of an exercise as the filename (without extension).
-This has two purposes: If you have nice file names you can
+This has two purposes: If you have nice file names you can
automatically name the exercise. On the other hand this is helpful
during exercise sheet composition because it shows the name of
the corresponding file in the compiled file.
@@ -261,7 +261,7 @@ There is also a related option:
\lstinline|\author| macro for the general author of a course but
there are different authors for individual exercises or all
exercises in general, you can set this key. Currently only
- exercisesheets-baemer uses this for the footline, while
+ exercisesheets-baemer uses this for the footline, while
\option{author} is used for the headline.
\end{description}
@@ -288,14 +288,14 @@ The following \param{options} are supported:
Useful to inform students when the sheet is due. If you want a note consisting
of more than one line split at a particular position, use
\verb|\protect\linebreak|.
- \item[\option{title=\param{title}}]
- Directly set the sheet title. When this option is used, different
+ \item[\option{title=\param{title}}]
+ Directly set the sheet title. When this option is used, different
page numbering conventions are used. This is useful to
typeset exams (combined with the next option).
- \item[\option{number within sheet\opt{=\param{true/false}}}]
+ \item[\option{number within sheet\opt{=\param{true/false}}}]
Deviate from the usual numbering theme and
- restart from one for exercises on the sheet. The previous
- counter value is restored after the sheet, so you can insert
+ restart from one for exercises on the sheet. The previous
+ counter value is restored after the sheet, so you can insert
a special sheet.
\item[\option{author=\param{author}}] Set the author included in the sheet
head. By default, the value passed to \verb|\author| is used.
@@ -307,10 +307,10 @@ The following \param{options} are supported:
sheet head. By default, the value passed to \verb|\date| is used.
\item[\option{beamerwithheadline\opt{=\param{true/false}}}] Controls whether 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.
- \item[\option{beamerwithfootline\opt{=\param{true/false}}}]
+ \item[\option{beamerwithfootline\opt{=\param{true/false}}}]
The same for the footer.
- \item[\option{beameruseblocks\opt{=\param{true/false}}}]
- Controls whether the exercise title is shown inside a
+ \item[\option{beameruseblocks\opt{=\param{true/false}}}]
+ Controls whether the exercise title is shown inside a
beamer block (\param{true}) or a simple colorbox
(\param{false}, the default). Depending on your style a
block might look fancier, but it usually consume more space.
@@ -349,17 +349,17 @@ supported:
for later use with \verb|\restatestask[|%
\param{which}], where \param{which} is either \verb|main|
(default) or the number of a sub task.
- \item[\option{points=\param{number/oral/sum}}] Assign this
- exercise \param{number} points. By default, exercises are
+ \item[\option{points=\param{number/oral/sum}}] Assign this
+ exercise \param{number} points. By default, exercises are
unlabelled. \param{oral} works the same way as the option
- \option{oral}. The value \param{sum} displays the sum of all
- occurrences of \verb|\points| within the exercise: Ordinary and
- bonus points are treated separately. If there are only bonus
- points, the option \option{bonus} is automatically triggered. To
- undo this, either delete the \verb|.aux| file or explicitly use
+ \option{oral}. The value \param{sum} displays the sum of all
+ occurrences of \verb|\points| within the exercise: Ordinary and
+ bonus points are treated separately. If there are only bonus
+ points, the option \option{bonus} is automatically triggered. To
+ undo this, either delete the \verb|.aux| file or explicitly use
\verb|\points[bonus=false]{\param{number}}| for at least one
subexercise. Points can be summed up also during a single pass
- by using the Lua interface.
+ by using the Lua interface.
\item[\option{oral}] Label this exercise as \emph{oral}. This supersedes and is
superseded by the option \option{points}.
\item[\option{pointsinfo=\param{text}}] Supply \param{text} as additional
@@ -377,22 +377,22 @@ supported:
\item[\option{sample}] Include this exercise (and its solution) in while compiling
sample solutions.
\item[\option{beamersolution}] For beamer variant only. If this option
- is set all normal solutions will not be included and only
+ is set all normal solutions will not be included and only
\option{beamersolution}s are typeset.
- \item[\option{framed}] For beamer variant only, simply ignored
+ \item[\option{framed}] For beamer variant only, simply ignored
elsewhere. If this option
- is set for a normal solution, its content will be put on one or
- more frames. Use \verb|\newframe| to start a new frame. This
- option is especially helpful if you provide your own definitions
+ is set for a normal solution, its content will be put on one or
+ more frames. Use \verb|\newframe| to start a new frame. This
+ option is especially helpful if you provide your own definitions
of \verb|\only| etc. and/or use the \option{beamercompatibility}.
- for non-beamer compilation. \verb|\newframe|
+ for non-beamer compilation. \verb|\newframe|
is already defined as \verb|\relax| in non-beamer \exsh,
even without invoking \option{beamercompatibility}.
\item[\option{fragile}] For beamer variant only and only
used combined with framed, simply ignored elsewhere. Frames are
declared as \texttt{fragile} und parsing of \verb|\newframe|
etc. is done via Lua\LaTeX. Thus Lua\LaTeX is required
- (and this requires font setup via fontspec etc.), but
+ (and this requires font setup via fontspec etc.), but
you do not have to use any Lua code yourself. Mostly useful
for listings and other verbatim stuff within solutions.
\end{description}
@@ -411,13 +411,13 @@ environment.
\includeexercise*(*\param{file name}*)
\end{lstlisting}
-Both load the exercise from exercisespath/\param{file name}. Note
-that the exercise environment must be contained in the file. The
+Both load the exercise from exercisespath/\param{file name}. Note
+that the exercise environment must be contained in the file. The
starred version is helpful for faster skipping of unused exercises.
In this case, the file is not opened to search for labels. Whenever
the exercise is not skipped and you use the starred version and also
-use labels within the exercise file, \exsh outputs an error. This is
-done to ensure that references are not overlooked when the exercise
+use labels within the exercise file, \exsh outputs an error. This is
+done to ensure that references are not overlooked when the exercise
is actually skipped later.
\subsection{Including Hints}
@@ -463,19 +463,19 @@ TODO markers (s.a.) the warning will be issued nevertheless.
\end{lstlisting}
\subsection{Explicitly Stating Tasks}
-In principle, \exsh aims to be very lightweight and there is not
+In principle, \exsh aims to be very lightweight and there is not
much mandatory structure inside exercises. Furthermore, the
\verb|enumi| counter is used for sub-exercise. There are, however,
-situations where we want more explicit structure, for instance to
+situations where we want more explicit structure, for instance to
have special font for the main task or the subtasks or to reuse
-some of the tasks later. This is especially handy if using the
+some of the tasks later. This is especially handy if using the
beamer variant where the original task and a part of the solution might be on different slides. In the future it might be possible to
use other counters then \verb|enumi|, which is also only possible
if sub-exercises are not simply \verb|\item|s in
\verb|enumerate|. If you want to reuse the main or any subtasks
you may use \verb|\restatetask| or \verb|\restatetaskbeamer|
(this shows noting if not compiled with beamer). There is also
-a starred version (\verb|\restatetask*| /
+a starred version (\verb|\restatetask*| /
\verb|\restatetaskbeamer*|) for each of them, which adds a newline.
All four have an optional argument that allows to restate
a subtask instead of the main task. This argument is either
@@ -483,7 +483,7 @@ a subtask instead of the main task. This argument is either
\option{cur} for the current subtask. Using \option{headerrestate}
for your solution will automatically restate the current
task within the beamer solution header (does noting without
-beamer).
+beamer).
@@ -505,7 +505,7 @@ beamer).
\end{solution}
\subtask{B is true}
\begin{solution}[framed]
- We already know: \restatestask[1] and
+ We already know: \restatestask[1] and
\restatestask[2], therefore B is also true.
\end{solution}
\end{subtasks}
@@ -516,14 +516,14 @@ beamer).
While the global reference labels set via varioref (if loaded)
are nice for references to subexercises far away, always mentioning
the exercise number seems superfluous. Furthermore, for usage in indices etc. you might want to use the arabic representation instead. This is what the commands \verb|\subexnref| and
-\verb|\subexlref| are designed for. However, both of them still
+\verb|\subexlref| are designed for. However, both of them still
require an ordinary label, which is not allowed in
exercises loaded with \verb|\loadexercise*|.
For this purpose \verb|\inexlabel| can be used which is just a
normal label that is not redefined to produce an error.
Furthermore, we define a counter \verb|subex| (which is
currently just an alias for enumi, but this might change). You can
-use this counter (alias) with common commands like
+use this counter (alias) with common commands like
\verb|\arabic| or \verb|\alph|.
\begin{lstlisting}
@@ -546,7 +546,7 @@ use this counter (alias) with common commands like
\subsection{Setting Options}
-Options can be given at different places.
+Options can be given at different places.
\begin{enumerate}
\item As local options to one of the environments.
\item As package options: This is convenient for global options but suffers
@@ -658,7 +658,7 @@ values:
Default: \verb|\ifdef{\color}{\color{red}}{}\bfseries|
\end{description}
-\subsection{Controlling the Spacing and Page Handling}
+\subsection{Controlling the Spacing, Page Handling and Separations between Elements}
The following options allow fine-tuning of the spacing:
\begin{description}
@@ -702,6 +702,46 @@ at the end of each sheet:
Default: \texttt{\string\clearpage}
\end{description}
+The following option controls what follows after the string
+\option{strings/solution} within a solution header. Using this, you can disable a solution header completely or, for instance, add
+a horizontal bar below each solution title.
+\begin{description}
+ \item[\option{solution title separator=\param{content}}] Inserted directly after \option{strings/solution} in a solution title:\\
+ Default: \verb|:\par|
+\end{description}
+
+\subsection{Controlling the Sectioning (beta)}
+
+By default, exercises are sections and sheets are parts. They use
+the respective counters and commands. This is impractical, if you
+want to include exercise ``sheets'' as, e.g., a subsection within
+a section of a book or article. While the page handling options
+already allow to dismiss page breaks, sectioning commands might
+still break your layout or structure. Since version \verb|0.15| you
+can use your own counters and commands to start sheets and
+(to a certain degree) exercises. Exercise are currently still
+started by \verb|\@startsection| with the counter set to
+\option{exercise counter}, but the level set to 1 (e.g. section).
+This will likely change with one of the next versions, but needs
+some testing. Thus, if you use any of these options, watch for
+undesired consequences and report them via gitlab if possible.
+
+\begin{description}
+ \item[\option{sheet sectioning cmd=\param{macro}}] This macro is
+ called only in one place in the following way:
+ \verb|\macro[short title{long title}|, so it
+ must take one argument in [brackets] and one normal argument.\\
+ Default: \verb|\part|
+ \item[\option{sheet counter=\param{counter}}] This counter will be
+ incremented wit every sheet. There was always an internal counter
+ \verb|sheetid| used to distinguish sheets for hyperref even if
+ \verb|part|s value changed. Do not use this counter here, as it will have strange effects (incremented twice).\\
+ Default: \verb|part|
+ \item[\option{exercise counter=\param{counter}}] This counter will
+ be incremented wit every exercise (usually within each sheet).
+ Default: \verb|section|
+\end{description}
+
\subsection{Special Code for Solutions}
\begin{lstlisting}
\ifsolutions{(*\param{if true}*)}{(*\param{if false}*)}
@@ -754,7 +794,7 @@ Users of \texttt{tikz} should be familiar with the concept.
\subsection{Control Skipping of Custom Macros in Skipped Exercises}
\begin{description}
- \item[\option{custom skip macro=\param{macro}}]
+ \item[\option{custom skip macro=\param{macro}}]
\end{description}
If an exercise is not printed, some macros like \texttt{\string\label{}}
@@ -762,7 +802,7 @@ are processed nevertheless. However, if you define your own macro
using one of these, then this macro will be completely ignored
if the exercise containing it is skipped. This option allows to
define a custom handler for your macros. The most common use
-checks for your custom macros with
+checks for your custom macros with
nested \texttt{\string\ifstrequal}s and then either
executes a custom skipper, replaces your macro with
the standard version or uses \texttt{\string\expandafter} to
@@ -793,9 +833,9 @@ Example:
\label{sec:lua}
Since version 0.11 there is a Lua interface for the exercise
-environment. This interface will offer roughly the same features.
-Its main purpose will be allowing to reorder sub-exercises more
-easily and to offer more dynamic options for the display of
+environment. This interface will offer roughly the same features.
+Its main purpose will be allowing to reorder sub-exercises more
+easily and to offer more dynamic options for the display of
solutions (one combined solution or single after each sub-%
exercise). %TODO finish
@@ -834,14 +874,34 @@ If you leave out the \option{solutions} option in you main file, running
solutions and \texttt{pdflatex solutions.tex} will create \texttt{solutions.pdf}
with solutions.
-This also works well in combination with a make file that generates
-\texttt{solutions.tex}.
+This also works well in combination with a makefile that generates
+\texttt{solutions.tex} as a temporary file.
+\subsection{Compatibilty with make4ht and tex4ebook}
+Since version \verb|0.15| this package can be used with make4ht and tex4ebook in non-beamer mode. Some code for the sheet and exercise header already provides a similar alignment as when producing PDF files. If your goal is an exercise (or solution) document within a single HTML file that looks as similar to the PDF as possible, consider \url{https://tex.stackexchange.com/questions/605478/}, \url{https://tex.stackexchange.com/questions/662445} and \url{https://tex.stackexchange.com/questions/630992}.
\section{Changelog}
\label{sec:changelog}
\begin{itemize}
+ \item[v. 0.15:] 2023-11-30
+ \begin{itemize}
+ \item new option \option{solution title separator}
+ (initially set to\verb|:\par|). Among other things, this
+ allows for solutions without any caption or header by
+ setting \option{solution title separator},~
+ \option{solution title font} as well as
+ \option{strings/solution} to \verb|\relax|.
+ \item initial support for \verb|make4ht| and
+ \verb|tex4ebook| by avoiding certain behavior when these
+ modes are used. Note that both are incompatible with beamer
+ mode.
+ \item initial decoupling of exercise and sheet from
+ sections and parts using the new options (defaults in
+ parenthesis) \option{sheet sectioning cmd} (\verb|\part|),
+ \option{sheet counter} (\verb|part|) and
+ \option{exercise counter} (\verb|section|).
+ \end{itemize}
\item[v. 0.14:] 2023-02-06
\begin{itemize}
\item new option \option{headerrestate} to restate
@@ -861,7 +921,7 @@ This also works well in combination with a make file that generates
\item bugfix: \verb|\begingroup| and \verb|\endgroup|
within \verb|\subtask| now contain everything up to the
next \verb|\subtask|.
- \item \verb|\restatestask| has now a starred version that
+ \item \verb|\restatestask| has now a starred version that
adds a newline and beamer versions for both the
regular and the starred version. Furthermore, there
is an argument \option{cur} to restate the current
@@ -886,7 +946,7 @@ This also works well in combination with a make file that generates
\begin{itemize}
\item Local references and the subex counter
\item Lua interface (not documented yet, see example and example file)
- \item Framed solutions can now be fragile, however this
+ \item Framed solutions can now be fragile, however this
also require Lua\LaTeX (but not using the Lua Interface).
\item beamer version is now included (no separate package)
\item some bug fixes
@@ -896,9 +956,9 @@ This also works well in combination with a make file that generates
\end{document}
-%%% Local Variables:
+%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
-%%% End:
+%%% End:
%%% Local IspellDict: british