From 14d99d3e545f4db9381dc9da8616ffdd33962ce5 Mon Sep 17 00:00:00 2001 From: Frank Fuhlbrück Date: Thu, 7 Mar 2024 13:24:24 +0100 Subject: v0.16: embedded mode --- exercisesheets.sty | 150 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 123 insertions(+), 27 deletions(-) (limited to 'exercisesheets.sty') 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{}#1% \exsh@inshtml{} @@ -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}% -- cgit v1.2.3