diff options
| -rw-r--r-- | exercisesheets-beamer.sty | 126 |
1 files changed, 106 insertions, 20 deletions
diff --git a/exercisesheets-beamer.sty b/exercisesheets-beamer.sty index db1d3f0..4a2d64b 100644 --- a/exercisesheets-beamer.sty +++ b/exercisesheets-beamer.sty @@ -29,6 +29,7 @@ \RequirePackage{etoolbox}[2008/06/28] \RequirePackage{scrlfile} +\RequirePackage{environ} \RequirePackage{pgfkeys} \RequirePackage{keyval} @@ -59,6 +60,7 @@ \newif\ifexsh@pointsfloatright \newif\ifexsh@bonus \newif\ifexsh@abbrev +\newif\ifexsh@filenameasexercisename \pgfkeys{/exsh/.is family,/exsh, solutions/.is choice, @@ -72,6 +74,8 @@ solutions/.default=true, forcesample/.is if=exsh@forcesample, forcesample/.default=true, + filenameasexercisename/.is if=exsh@filenameasexercisename, + filenameasexercisename/.default=true, beamersolution/.is if=exsh@beamersolution, beamersolution/.default=true, defersolutiontitle/.is if=exsh@defersolutiontitle, @@ -82,7 +86,10 @@ gradingguides/.default=true, only/.initial={-}, all/.style={/exsh/only={-}},all/.value forbidden, - solutionsby/.code={\def\exsh@solutionsby{#1}},solutionsby/.value required, + solutionsby/.code={\def\exsh@solutionsby{#1}}, + solutionsby/.value required, + exercisespath/.code={\def\exsh@exercisespath{#1}}, + exercisespath/.value required, bonus/.is if=exsh@bonus, bonus/.default=true, inplace/.is if=exsh@inplace, @@ -156,6 +163,7 @@ oral/.style={/exsh/points=oral},oral/.value forbidden, inplace/.initial={false}, sample/.initial={false}, + filenameasexercisename/.initial={false}, pointsfloatright/.initial={false}, bonus/.initial={false}, nobonus/.style={/exsh/bonus=false},nobonus/.value forbidden, @@ -510,13 +518,14 @@ \long\def\exsh@skipstuff#1{% \ifstrequal{#1}{\begin}{\exsh@skipstuff@begin}{% \ifstrequal{#1}{\end}{\exsh@skipstuff@end}{% + \ifstrequal{#1}{\includeexercise}{\exsh@skipstuff@incex}{% \ifstrequal{#1}{\label}{\exsh@skipstuff@label}{% \ifstrequal{#1}{\input}{\exsh@skipstuff@input}{% \ifstrequal{#1}{\exsh@skipstuff@endfile}{\currfile@pop\exsh@skipstuff}{% \ifstrequal{#1}{\setcounter}{\expandafter\exsh@skipstuff\setcounter}{% \ifstrequal{#1}{\item}{\ifdef{\@enumctr}{%\@hyper@itemtrue% \refstepcounter{\@enumctr}}{}}{}% - \pgfkeysvalueof{/exsh/custom skip macro}{#1}}}}}}}% + \pgfkeysvalueof{/exsh/custom skip macro}{#1}}}}}}}}% } \let\exshskipcontinue\exsh@skipstuff \long\def\exsh@skipcustomstuff#1{\exshskipcontinue} @@ -535,7 +544,7 @@ \ifthenelse{\equal{\jobname}{\currfilebase}}{}{% \ifcsdef{exsh@autolabel@\currfilebase}{}{% \csdef{exsh@autolabel@\currfilebase}{}% - \label{ex:\currfilebase}}}% + \exsh@autolabel{ex:\currfilebase}}}% }{}% \ifinlist{#1}{\exsh@enums}{% \exsh@skipstuff@beginenum @@ -581,7 +590,22 @@ \expandafter\exsh@skipstuff\exsh@inputfilecontent\exsh@skipstuff@endfile } -\long\def\exsh@sheethead{% +\def\exsh@skipstuff@incex{% + \@ifstar\exsh@skipstuff@incex@@\exsh@skipstuff@incex@% +} + +\newcommand{\exsh@skipstuff@incex@}[2][]{% +\exsh@skipstuff\input{% + \ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}#2}% +} + +\newcommand{\exsh@skipstuff@incex@@}[2][]{% +\refstepcounter{section} +\exsh@autolabel{ex:#2} +\exsh@skipstuff +} + +\def\exsh@sheethead{% \pgfkeysgetvalue{/exsh/title}{\exsh@tmp}% \ifexsh@solutions \expandafter\edef\expandafter\exsh@tmp{\expandonce\exsh@tmp:\noexpand~\pgfkeysvalueof{/exsh/strings/solutions}}% @@ -631,9 +655,12 @@ {\csname the#1\endcsname\autodot\enskip}}% }{} +%Do nout use \let here as \label may change before its use +\def\exsh@autolabel{\label} + \newenvironment*{exercise}[1][]{% % TODO: \edef is not safe with luatex and umlauts, only fixed for "oral" for now - \pgfkeys{exsh,every exercise,#1}% + \pgfkeys{exsh,every exercise,#1,includeoverride}% \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/points}}}{% \def\exsh@points{}% \def\exsh@shortpoints{}% @@ -712,7 +739,7 @@ \ifthenelse{\equal{\jobname}{\currfilebase}}{}{% \ifcsdef{exsh@autolabel@\currfilebase}{}{% \csdef{exsh@autolabel@\currfilebase}{}% - \label{ex:\currfilebase}}}% + \exsh@autolabel{ex:\currfilebase}}}% % Use \leavevmode to ensure proper distances above environments that start % with a new \par. Make sure that a \label does not mess up the layout. \@ifnextchar\label{\exsh@label}{\leavevmode\ignorespaces}% @@ -735,6 +762,41 @@ \renewcommand{\insertenumlabel}{\alph{enumi})} }% + +\exshset{includeoverride/.style={}} +\def\includeexercise{% + \@ifstar\exsh@includeexercise@\exsh@includeexercise% +} + +\newcommand{\exsh@includeexercise}[2][]{% +\ifbool{exsh@filenameasexercisename}{% + \exshset{includeoverride/.style={name={#2},#1}}% +}{% + \exshset{includeoverride/.style={#1}}% +}% +\input{\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}#2} +\exshset{includeoverride/.style={}} +} + +\newcommand{\exsh@includeexercise@}[2][]{% +\ifbool{exsh@filenameasexercisename}{% + \exshset{includeoverride/.style={name={#2},#1}}% +}{% + \exshset{includeoverride/.style={#1}}% +}% +\begingroup +%auto labelling is still allowed, but other labels are forbidden +%here we may use \let as the definition is close to its use +\let\exsh@autolabel\label +\def\label##1{% + \PackageError{exercisesheets-beamer}{\string\label{##1}\space + inside \string\includeexercise*}{}% +} +\input{\ifdefvoid{\exsh@exercisespath}{}{\exsh@exercisespath/}#2} +\endgroup +\exshset{includeoverride/.style={}} +} + \AfterPackage*{varioref}{ \labelformat{section}{\pgfkeysvalueof{/exsh/strings/exercise}~\arabic{section}} \labelformat{enumi}{\arabic{section}.\alph{enumi}} @@ -793,7 +855,7 @@ }{}% \next }{% - \ifbool{exsh@framed}{\end{frame}}{} +% \ifbool{exsh@framed}{\end{frame}}{} \ifbool{exsh@beamersolution}{}{% \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{% \ifbool{exsh@oralsolutions}{\clearpage}{}% @@ -817,6 +879,24 @@ }{}% } + +\long\def\exsh@processframes#1\newframe{% +\ifstrequal{#1}{}{}{% +\clearpage +\begin{frame}[t] + \solutiontitle[\textwidth] + #1 +\end{frame}% +\exsh@processframes% +}%no whitespace here is crucial for end detecttion +} + +\long\def\exsh@collectedframe#1{ +\exsh@processframes#1\newframe\newframe +} + + + \def\exsh@startsolution{% \ifnum\@enumdepth=0 \clearpage @@ -833,10 +913,7 @@ \ifbool{exsh@defersolutiontitle}{}{% \ifhmode \linebreak\fi\exsh@solutiontitle{\linewidth} }% - \ifbool{exsh@framed}{\clearpage - \begin{frame}[t,fragile,environment=solution] - \solutiontitle - }{}% + \ifbool{exsh@framed}{\Collect@Body\exsh@collectedframe}{}% }% \long\def\exsh@skipsolution#1{% @@ -875,7 +952,7 @@ }{}% \next }{% - \ifbool{exsh@framed}{\end{frame}}{} +% \ifbool{exsh@framed}{\end{frame}}{} \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{% \ifbool{exsh@oralsolutions}{\clearpage}{}% }{% @@ -1017,14 +1094,23 @@ \setbeamertemplate{headline}{% -\leavevmode% - \begin{beamercolorbox}[wd=\paperwidth,ht=3.5em,dp=1.375ex]% - {frametitle}\footnotesize - \hspace*{2ex}{\pgfkeysvalueof{/exsh/subject font}\pgfkeysvalueof{/exsh/subject}} \hfill - {\pgfkeysvalueof{/exsh/semester font}\pgfkeysvalueof{/exsh/semester}}\hspace{2ex}\hfil\linebreak - \hspace*{2ex}{\pgfkeysvalueof{/exsh/author font}\exsh@author}\hfill - {\pgfkeysvalueof{/exsh/date font}\pgfkeysvalueof{/exsh/date}}% - \hspace{2ex}\hfil\linebreak\vspace{-1em} +% \leavevmode% + \begin{beamercolorbox}[wd=\paperwidth,vmode]{frametitle} + \vspace{0.4em} + \leavevmode + \begingroup + \footnotesize% + \hspace*{2ex}{\pgfkeysvalueof{/exsh/subject font}% + \pgfkeysvalueof{/exsh/subject}} \hfill% + {\pgfkeysvalueof{/exsh/semester font}% + \pgfkeysvalueof{/exsh/semester}}\hspace{2ex}\hfil% + \vspace{1mm}\linebreak% + \hspace*{2ex}{\pgfkeysvalueof{/exsh/author font}\exsh@author}% + \hfill{\pgfkeysvalueof{/exsh/date font}% + \pgfkeysvalueof{/exsh/date}}% + \hspace{2ex}\hfil%\vspace{-1em} + \endgroup + \vspace{0.4em} \end{beamercolorbox}% \vspace{3mm} } |
