aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exercisesheets.sty150
-rw-r--r--exercisesheets.tex49
2 files changed, 168 insertions, 31 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty
index 71020cd..403dc1f 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.15.1}
-\def\exsh@date{2023/12/14}
+\def\exsh@version{0.16}
+\def\exsh@date{2024/03/07}
\ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
\message{`Typesetting of exercise sheets' \exsh@version\space <\exsh@date>}
@@ -62,6 +62,12 @@
\fi
\newif\ifexsh@patchenumerate\exsh@patchenumeratetrue
+\newif\ifexsh@settitle\exsh@settitletrue
+\newif\ifexsh@patchpagenumbers\exsh@patchpagenumberstrue
+\newif\ifexsh@usestartsection\exsh@usestartsectiontrue
+\newif\ifexsh@firstexonsheet
+\def\exsh@firstexonsheettrue{\global\let\ifexsh@firstexonsheet\iftrue}
+\def\exsh@firstexonsheetfalse{\global\let\ifexsh@firstexonsheet\iffalse}
\newif\ifexsh@savetasks
\newif\ifexsh@solutions
\newif\ifexsh@oralsolutions
@@ -135,6 +141,37 @@
\pgfkeys{/exsh/.is family,/exsh,
patchenumerate/.is if=exsh@patchenumerate,
patchenumerate/.default=true,
+ settitle/.is if=exsh@settitle,
+ settitle/.default=true,
+ patchpagenumbers/.is if=exsh@patchpagenumbers,
+ patchpagenumbers/.default=true,
+ usestartsection/.is if=exsh@usestartsection,
+ usestartsection/.default=true,
+ embedded/.code={%
+ \exsh@patchenumeratefalse
+ \exsh@settitlefalse
+ \exsh@patchpagenumbersfalse
+ \exsh@usestartsectionfalse
+ \pgfkeysalso{secnumdepth=keep}%
+ \def\exhs@sheetnoheader[##1]##2{}%
+ \newcounter{exshsheet}
+ \newcounter{exshexercise}
+ \pgfkeysalso{
+ sheet sectioning cmd=\exhs@sheetnoheader,
+ sheet counter=exshsheet,
+ exercise counter=exshexercise,
+ sheet start page action=\relax,
+ sheet end page action=\relax,
+ }%
+ },
+ minskips/.code={%
+ \pgfkeysalso{
+ above sheet title skip=0pt,
+ below sheet header skip=0pt,
+ above first exercise skip=0pt,
+ below exercise title skip=0pt,
+ }%
+ },
savetasks/.is if=exsh@savetasks,
savetasks/.default=true,
solutions/.is choice,
@@ -272,6 +309,8 @@
\pgfkeys{exsh,
%general package options
patchenumerate/.initial=true,
+ settitle/.initial=true,
+ patchpagenumbers/.initial=true,
custom skip macro/.initial=\exsh@skipcustomstuff,
showtodos/.initial={false},
hidetodos/.style={/exsh/showtodos=false},
@@ -400,6 +439,7 @@
% and a mandatory argument
sheet sectioning cmd/.initial={\part},
sheet counter/.initial={part},
+ secnumdepth/.initial={-1},
exercise counter/.initial={section},
%
% font specifications
@@ -431,6 +471,7 @@
above solutionsby skip/.initial={1ex},
below sheet header skip/.initial={4ex plus 1ex minus .5ex},
above exercise skip/.initial={3ex plus 1ex minus .5em},
+ above first exercise skip/.initial={3ex plus 1ex minus .5em},
below exercise title skip/.initial={\parskip},
above solution skip/.initial={1ex},
above hint skip/.initial={1ex},
@@ -576,14 +617,20 @@
\immediate\write\@auxout{\string\gdef\string\exsh@lastsheet{\arabic{\pgfkeysvalueof{/exsh/sheet counter}}}}%
}
-\numberwithin{page}{\pgfkeysvalueof{/exsh/sheet counter}}
-\renewcommand{\thepage}{\arabic{page}}%changed for every sheet
-\setcounter{secnumdepth}{-1}
+\ifexsh@patchpagenumbers
+ \numberwithin{page}{\pgfkeysvalueof{/exsh/sheet counter}}
+ \renewcommand{\thepage}{\arabic{page}}%changed for every sheet
+\fi
+\ifthenelse{\equal{\pgfkeysvalueof{/exsh/secnumdepth}}{keep}}{}{
+ \setcounter{secnumdepth}{\pgfkeysvalueof{/exsh/secnumdepth}}
+}
\AfterPackage*{hyperref}{%
% make PDF destinations unique:
\def\theHsection{\arabic{sheetid}.\arabic{\pgfkeysvalueof{/exsh/exercise counter}}}%
- \def\theHpage{\arabic{sheetid}-\arabic{page}}%
+ \ifexsh@patchpagenumbers
+ \def\theHpage{\arabic{sheetid}-\arabic{page}}%
+ \fi
%
% open bookmarks when typesetting a single sheet
\AtEndPreamble{%
@@ -592,6 +639,8 @@
}%
}
+
+\ifexsh@settitle
% automatic title selection
\let\exsh@title\relax
\let\exsh@title@new\relax
@@ -613,6 +662,7 @@
\fi
}
+
\AtBeginDocument{%
\ifexsh@solutions
\title{\exsh@title: \pgfkeysvalueof{/exsh/strings/solutions}}%
@@ -620,6 +670,8 @@
\title{\exsh@title}
\fi
}
+\fi
+
\newcounter{sheetid}% only used to disambiguate hyperref labels
\newenvironment{sheet}[1][]{%
\pgfkeys{exsh,every sheet,#1}%
@@ -629,9 +681,13 @@
\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{\pgfkeysvalueof{/exsh/sheet counter}}-\arabic{page}}%
+ \ifexsh@patchpagenumbers
+ \def\thepage{\arabic{\pgfkeysvalueof{/exsh/sheet counter}}-\arabic{page}}%
+ \fi
}{%
- \def\thepage{\arabic{page}}%
+ \ifexsh@patchpagenumbers
+ \def\thepage{\arabic{page}}%
+ \fi
}%
\ifexsh@exnumsheet
\edef\exsh@exnumstore{\arabic{\pgfkeysvalueof{/exsh/exercise counter}}}
@@ -859,8 +915,8 @@
\global\def\exsh@alignright#1{\hfill #1}%
\else%--------- NON-BEAMER: ---------------------------------------
\ifexsh@html
- \global\def\exsh@part[#1]#2{#2}
- \exshset{sheet sectioning cmd/.initial={\exsh@part}}
+% \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>}
@@ -920,10 +976,18 @@
}%
\endgroup
}%
- \unskip
- \vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax
- \stepcounter{page}%
-}
+ \ifdim\z@=\pgfkeysvalueof{/exsh/below sheet header skip}\relax
+ \vskip-\parskip
+ \else
+ \unskip\vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax
+ \fi
+% \unskip
+% \vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax
+ \exsh@firstexonsheettrue
+ \ifexsh@patchpagenumbers%
+ \stepcounter{page}%
+ \fi
+}%
\fi
%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -975,7 +1039,7 @@
}{%
\exsh@sumuppointsfalse%
}%
- \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifthenelse{\equal{off}{\pgfkeysvalueof{/exsh/points}}}{%
\def\exsh@points{}%
\def\exsh@shortpoints{}%
}{%
@@ -1049,10 +1113,14 @@
\ifbool{exsh@hide}{%
\def\exsh@skipwhat{exercise}\exsh@skipstuff%
}{%
- \expandafter\exsh@startsection\exsh@tmp{\noindent%
+ \expandafter\exsh@startheader\exsh@tmp{\noindent%
\hbox to 0pt{\hss\pgfkeysvalueof{/exsh/exercisemark}}%
\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
+ \ifdim\z@=\pgfkeysvalueof{/exsh/below exercise title skip}\relax
+ \vskip-\parskip
+ \else
+ \unskip\vskip\pgfkeysvalueof{/exsh/below exercise title skip}\relax
+ \fi
\@afterindentfalse
% automatic label for the first exercise in every included file
\ifthenelse{\equal{\jobname}{\currfilebase}}{}{%
@@ -1083,7 +1151,7 @@
%%%%%%%%%%%%%%% BEGIN BEAMER-SPECIFIC: %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifexsh@beamer
-\newcommand{\exsh@startsection}[2][]{%
+\newcommand{\exsh@startheader}[2][]{%
\newpage
% \begin{block}{}
% \pgfkeysvalueof{/exsh/exercise title font}{#2}%
@@ -1115,13 +1183,40 @@
\fi
}%
\else%--------- NON-BEAMER: ---------------------------------------
-\newcommand{\exsh@startsection}[2][]{%
- \@startsection{\pgfkeysvalueof{/exsh/exercise counter}}{1}{\z@}%
- {\pgfkeysvalueof{/exsh/above exercise skip}}%
- {1em}% afterskip corrected below
- {\pgfkeysvalueof{/exsh/exercise title font}}%
- [#1]{#2}%
-}%
+\ifexsh@usestartsection
+ \newcommand{\exsh@startheader}[2][]{%
+ \@startsection{section}{1}{\z@}{%
+ \ifexsh@firstexonsheet
+ \pgfkeysvalueof{/exsh/above first exercise skip}%
+ \else
+ \pgfkeysvalueof{/exsh/above exercise skip}
+ \fi
+ }{1em}% afterskip corrected below
+ {\pgfkeysvalueof{/exsh/exercise title font}}%
+ [#1]{#2}%
+ \exsh@firstexonsheetfalse
+ }%
+\else
+ \newcommand{\exsh@startheader}[2][]{%
+ \ifexsh@firstexonsheet
+ \ifdim\z@=\pgfkeysvalueof{/exsh/above first exercise skip}\relax
+ \vskip-\parskip
+ \else
+ \unskip%
+ \vskip\pgfkeysvalueof{/exsh/above first exercise skip}\relax
+ \fi
+ \else
+ \ifdim\z@=\pgfkeysvalueof{/exsh/above exercise skip}\relax
+ \vskip-\parskip
+ \else
+ \unskip%
+ \vskip\pgfkeysvalueof{/exsh/above exercise skip}\relax
+ \fi
+ \fi
+ {\pgfkeysvalueof{/exsh/exercise title font} #2}%
+ \exsh@firstexonsheetfalse
+ }
+\fi
\fi
%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1250,7 +1345,7 @@
% code below breaks [] argument after \begin{enumerate}
% when beamer is used
% in beamer we set item labels separately
- % see beamer specific def. of \exsh@startsection
+ % see beamer specific def. of \exsh@startheader
\else%--------- NON-BEAMER: ---------------------------------------
\AtEndPreamble{%
\@ifpackageloaded{paralist}{}{%
@@ -1469,7 +1564,8 @@
\long\def\exsh@processframes#1\newframe{%
\ifstrequal{#1}{}{}{%
\clearpage
-\begin{frame}[t]
+\begin{frame}[t]{}
+` \unskip\vskip1pt\vskip-\parskip
\solutiontitle[\textwidth]
#1
\end{frame}%
diff --git a/exercisesheets.tex b/exercisesheets.tex
index 25ad9b8..30cbd1c 100644
--- a/exercisesheets.tex
+++ b/exercisesheets.tex
@@ -1,5 +1,5 @@
%% exercisesheets.tex
-%% Copyright 2008-2023 Sebastian Kuhnert, Frank Fuhlbrück
+%% Copyright 2008-2024 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
@@ -53,7 +53,7 @@
\usepackage[english,iso]{isodate}
\title{The \exsh Package}
\author{Sebastian Kuhnert\and Frank Fuhlbrück}
-\date{Version 0.15.1, \printdateTeX{2023/12/14}}
+\date{Version 0.16, \printdateTeX{2024/03/07}}
\begin{document}
\maketitle
@@ -64,7 +64,7 @@ finally combined into this package. Starting from Version 0.7, there was an alte
\subsection*{Licence}
-Copyright \textcopyright{} 2008--2023 Sebastian Kuhnert and Frank Fuhlbrück.
+Copyright \textcopyright{} 2008--2024 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
@@ -183,7 +183,43 @@ The following options are available:
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{settitle}\opt{=\param{true/false}}] If set to true
+ (which is the default),
+ the document \verb|\title| will be automatically set to the value
+ of \option{strings/sheets} and the value of \option{strings/
+ solutions} will be
+ appended if \option{solutions} is not \option{false}.
+ \item[\option{patchpagenumbers}\opt{=\param{true/false}}] If true
+ (default), pages will be numbered within sheets and page numbers
+ get a prefix of the form ``\param{sheet number}\verb|-|''.
+ \item[\option{usestartsection}\opt{=\param{true/false}}] If true
+ (default), the command \verb|\@startsection| is used to create
+ the header of any exercise as a section, which (among other
+ things) adds an entry to the TOC (if existent) at level 1
+ (usually corresponding to \verb|\section|).
+ \item[\option{embedded}\opt{=\param{true/false}}] Default: false.
+ Embedded mode allows for exercise ``sheets'' which do not
+ interfere with a surrounding document. More explicitly, it does
+ not interfere with \verb|secnumdepth|, defines special counters
+ \verb|exshsheet| and \verb|exshexercise| to use them for
+ \option{sheet counter} and \option{exercise counter},
+ respectively and sets all of \option{patchenumerate},
+ \option{settitle}, \option{patchpagenumbers} and
+ \option{usestartsection} to \option{false}.
+ An internally defined macro which basically does no extra
+ formatting or adding anything to the TOC is used as
+ \option{sheet sectioning cmd} instead of the usual \verb|part|.
+ Finally,
+ the \option{sheet start page action} and the
+ \option{sheet end page action} are both set to \verb|\relax|.
+ If you want to override any of this, do it after setting
+ \option{embedded} to \option{true}.
+ \item{\option{minskips\opt{=\param{true/false}}}} Default: false.
+ If true, the values of
+ \option{above sheet title skip},
+ \option{below sheet header skip},
+ \option{above first exercise skip} and
+ \option{below exercise title skip} are all set to 0pt.
\item[\option{showtodos} / \option{hidetodos}]
\verb|\TODO| markers
are hidden by default, this option switches their behavior. This
@@ -884,6 +920,11 @@ Since version \verb|0.15| this package can be used with make4ht and tex4ebook in
\label{sec:changelog}
\begin{itemize}
+ \item[v. 0.16:] 2024-03-07
+ \begin{itemize}
+ \item Embedded mode and most of the additional options it
+ automatically sets.
+ \end{itemize}
\item[v. 0.15.1:] 2023-12-14
\begin{itemize}
\item bugfix: beamer support was broken in 0.15 due to