aboutsummaryrefslogtreecommitdiff
path: root/exercisesheets.sty
diff options
context:
space:
mode:
Diffstat (limited to 'exercisesheets.sty')
-rw-r--r--exercisesheets.sty203
1 files changed, 181 insertions, 22 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty
index 29c2728..cad2a20 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -45,6 +45,9 @@
% configuration keys
+\newif\ifexsh@beamer
+\@ifclassloaded{beamer}{\exsh@beamertrue}{}
+
\newif\ifexsh@patchenumerate\exsh@patchenumeratetrue
\newif\ifexsh@savetasks
\newif\ifexsh@solutions
@@ -53,6 +56,16 @@
\newif\ifexsh@samplesolutions
\newif\ifexsh@exnumsheet
\newif\ifexsh@forcesample %force printing sample sol. of wrong type
+%For beamer only
+\ifexsh@beamer
+\newif\ifexsh@beamerwithheadline
+\newif\ifexsh@beameruseblocks
+\newif\ifexsh@defersolutiontitle
+\newif\ifexsh@framed
+\fi
+%Also only true for beamer, but we want to use it elsewhere
+\newif\ifexsh@beamersolution
+%%
\newif\ifexsh@gradingguides
\newif\ifexsh@inplace
\newif\ifexsh@sample
@@ -70,6 +83,10 @@
\PackageError{exercisesheets}{
beamercompatibility used twice}{}%
\else
+\ifexsh@beamer
+ %currently we do nothing if beamer is loaded,
+ %but this might change
+\else
%TODO:\only<>{A} -> {A} which breaks global effects of A
\let\pause\relax
\def\frame{}
@@ -92,6 +109,7 @@
\let\exsh@origenumerate\enumerate
\def\exsh@ovrlenumerate[##1]{\exsh@origenumerate}
\def\enumerate{\@ifnextchar[\exsh@ovrlenumerate\exsh@origenumerate}
+\fi
\exsh@beamercompatdonetrue
\fi
}
@@ -136,7 +154,30 @@
pointsfloatright/.default=true,
abbrev/.is if=exsh@abbrev,
abbrev/.default=true,
- %options from exercisesheets-beamer are ignored
+ beamercompatibility/.default={ignore},
+ beamercompatibility/.initial={ignore},
+ beamercompatibility/.code={\exsh@beamercompatibility}
+}
+\ifexsh@beamer
+\pgfkeys{exsh,
+ beamerwithheadline/.is if=exsh@beamerwithheadline,
+ beamerwithheadline/.default=true,
+ beameruseblocks/.is if=exsh@beameruseblocks,
+ beameruseblocks/.default=true,
+ beamersolution/.is if=exsh@beamersolution,
+ beamersolution/.default=true,
+ defersolutiontitle/.is if=exsh@defersolutiontitle,
+ defersolutiontitle/.default=true,
+ framed/.is if=exsh@framed,
+ framed/.default=true,
+ beamersolution/.initial={false},
+ beamerwithheadline/.initial={false},
+ beameruseblocks/.initial={false},
+ defersolutiontitle/.initial={false},
+ framed/.initial={false},
+}
+\else
+\pgfkeys{exsh,
beamerwithheadline/.default={ignore},
beamerwithheadline/.initial={ignore},
beamersolution/.default={ignore},
@@ -146,16 +187,16 @@
framed/.default={ignore},
framed/.initial={ignore},
framed/.code={\let\newframe\relax},
- beamercompatibility/.default={ignore},
- beamercompatibility/.initial={ignore},
- beamercompatibility/.code={\exsh@beamercompatibility},
}
+\fi
% store title data for sheet headers
\ifundef\subject{% \subject is only provided by KOMA classes
\newcommand{\subject}[1]{}%
\def\@subject{}%
}{}
+% beamer has subject, but not \@subject:
+\providecommand{\@subject}{}
\apptocmd{\subject}{\pgfkeys{/exsh/subject={#1}}}{}{}%
\ifdefempty{\@subject}{
\pgfkeys{exsh,subject/.initial={\PackageWarning{exercisesheets}{No \string\subject\space given}}}
@@ -231,6 +272,13 @@
exercisemark/.initial={},
difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden,
savetasks/.initial=false,
+}
+%beamer specific options
+\ifexsh@beamer
+\pgfkeys{exsh,
+}
+\fi
+\pgfkeys{exsh,
%
% translatable strings
strings/sheet/.initial={},
@@ -339,7 +387,7 @@
todo marker font/.initial=\ifdef{\color}{\color{red}}{}\bfseries,
%
% skip values
- below sheet headline skip/.initial={},
+ below slide headline skip/.initial={0mm},
above sheet title skip/.initial={4ex},
above sheet note skip/.initial={.7ex},
above solutionsby skip/.initial={1ex},
@@ -371,6 +419,15 @@
% allow further keys to be set
\def\exshset#1{\pgfkeys{exsh,#1}}
+\ifexsh@beamer
+\define@key{beamerframe}{t}[true]{% top
+ \beamer@frametopskip=-2pt\relax%
+ \beamer@framebottomskip=0pt plus 1fill\relax%
+ \beamer@frametopskipautobreak=\beamer@frametopskip\relax%
+ \beamer@framebottomskipautobreak=\beamer@framebottomskip\relax%
+}
+\fi
+
% automatic language selection
\AfterEndPreamble{%
\exsh@provideonlytrue
@@ -577,6 +634,11 @@
\listadd{\exsh@nonenums}{asparablank}
\listadd{\exsh@nonenums}{inparablank}
\listadd{\exsh@nonenums}{list}
+\ifexsh@beamer
+ \let\exsh@hyper@itemtrue\relax
+\else
+ \def\exsh@hyper@itemtrue{\@hyper@itemtrue}
+\fi
\long\def\exsh@skipstuff#1{%
\ifstrequal{#1}{\begin}{\exsh@skipstuff@begin}{%
\ifstrequal{#1}{\end}{\exsh@skipstuff@end}{%
@@ -585,7 +647,7 @@
\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}}{}}{}%
+ \ifstrequal{#1}{\item}{\ifdef{\@enumctr}{\exsh@hyper@itemtrue\refstepcounter{\@enumctr}}{}}{}%
\pgfkeysvalueof{/exsh/custom skip macro}{#1}}}}}}}}%
}
\let\exshskipcontinue\exsh@skipstuff
@@ -666,6 +728,50 @@
\exsh@skipstuff
}
+\ifexsh@beamer
+\def\exsh@sheethead{%
+ \pgfkeysgetvalue{/exsh/title}{\exsh@tmp}%
+ \ifexsh@solutions
+ \expandafter\edef\expandafter\exsh@tmp{\expandonce\exsh@tmp:\noexpand~\pgfkeysvalueof{/exsh/strings/solutions}}%
+ \fi
+ \refstepcounter{part}%
+ \begin{frame}
+ \begin{block}{}
+ \centering\Large\exsh@tmp
+ \end{block}
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet header font}%
+ \ifexsh@solutions%
+ \ifdefvoid{\exsh@solutionsby}{}{%
+ \begingroup
+ \begin{block}{}
+ \pgfkeysvalueof{/exsh/solutionsby font}%
+ \vskip\pgfkeysvalueof{/exsh/above solutionsby skip}%
+ \relax%
+ \pgfkeysvalueof{/exsh/strings/solutionsby}%
+ ~\exsh@solutionsby\\\unskip%
+ \end{block}%
+ \endgroup
+ }%
+ \else
+ \fi
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/note}}}{%
+ }{%
+ \ifbool{exsh@samplesolutions}{}{%
+ \begingroup
+ \begin{block}{}
+ \pgfkeysvalueof{/exsh/sheet note font}%
+ \vskip\pgfkeysvalueof{/exsh/above sheet note skip}\relax
+ \pgfkeysvalueof{/exsh/note}\\\unskip%
+ \end{block}%
+ \endgroup
+ }%
+ }%
+ \endgroup
+% \stepcounter{page}%
+ \end{frame}
+}
+\else
\def\exsh@sheethead{%
\pgfkeysgetvalue{/exsh/title}{\exsh@tmp}%
\ifexsh@solutions
@@ -712,6 +818,7 @@
\vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax
\stepcounter{page}%
}
+\fi
\ifdef{\othersectionslevelsformat}{%
\renewcommand{\othersectionlevelsformat}[1]{%
@@ -855,10 +962,45 @@
\detokenize{\csname} exsh@sumptsbonus@\arabic{section}\endcsname{%
\arabic{exsh@ptsbonus@cur}%
}%
- }
+ }%
\fi
+ \ifexsh@beamer\clearpage\fi
}
\newcommand{\exsh@label}[2]{#1{#2}\leavevmode\ignorespaces}
+
+\ifexsh@beamer
+\newcommand{\exsh@startsection}[2][]{%
+ \newpage
+% \begin{block}{}
+% \pgfkeysvalueof{/exsh/exercise title font}{#2}%
+% \end{block}
+ \ifbool{exsh@beameruseblocks}{%
+ \begingroup
+ \usebeamercolor{block title}
+ \setbeamercolor{block body}{bg=bg,fg=fg}
+ \block{}{\pgfkeysvalueof{/exsh/exercise title font}{#2}}%
+ \endblock
+ \endgroup
+ }{
+ \begin{beamercolorbox}[rounded=true,wd={\textwidth}]%
+ {block title}
+ \pgfkeysvalueof{/exsh/exercise title font}{#2}
+ \end{beamercolorbox}
+ }
+ \ifexsh@patchenumerate
+ \setbeamertemplate{enumerate items}{\insertenumlabel}
+ \renewcommand{\insertenumlabel}{
+ \ifnum\@enumdepth=1
+ \alph{enumi})
+ \else\ifnum\@enumdepth=2
+ \arabic{enumii}.
+ \else
+ \roman{enumiii}
+ \fi\fi
+ }
+ \fi
+}%
+\else
\newcommand{\exsh@startsection}[2][]{%
\@startsection{section}{1}{\z@}%
{\pgfkeysvalueof{/exsh/above exercise skip}}%
@@ -866,6 +1008,7 @@
{\pgfkeysvalueof{/exsh/exercise title font}}%
[#1]{#2}%
}%
+\fi
\exshset{includeoverride/.style={}}
@@ -1007,7 +1150,15 @@
}{%
\unskip)%
}
-\newenvironment{solution}[1][]{%
+
+
+\ifexsh@beamer
+ \let\exsh@postsolutionclear\clearpage
+\else
+ \let\exsh@postsolutionclear\par
+\fi
+\providecommand{\solution}{}
+\renewenvironment{solution}[1][]{%
\pgfkeys{exsh,every solution,#1,solution font}%
\ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
\ifbool{exsh@oralsolutions}{%
@@ -1027,12 +1178,17 @@
\let\next\exsh@startsolution
}{}%
}{}%
+ \ifbool{exsh@beamersolution}{%
+ \let\next\exsh@skipsolution
+ }{}%
\next
}{%
- \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
- \ifbool{exsh@oralsolutions}{\par}{}%
- }{%
- \ifbool{exsh@nonoralsolutions}{\par}{}%
+ \ifbool{exsh@beamersolution}{}{%
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \ifbool{exsh@oralsolutions}{\exsh@postsolutionclear}{}%
+ }{%
+ \ifbool{exsh@nonoralsolutions}{\exsh@postsolutionclear}{}%
+ }%
}%
}
@@ -1208,7 +1364,10 @@
\ifluatex
-\usepackage{luacode}
+ \let\exsh@dlua\directlua
+\else
+ \def\exsh@dlua#1{}
+\fi
%change only some catcodes to
\begingroup
@@ -1222,8 +1381,8 @@
\catcode`\~=11
\catcode`\\=11
%% Expanded, when \catcode`\^^M=12 holds
-!global!long!def!exsh@start@Lexercise@#1\end{Lexercise}< %
- !directlua<exsh_cur_exercise=exercise ({#1})> %
+!global!long!def!exsh@start@Lexercise#1\end{Lexercise}< %
+ !exsh@dlua<exsh_cur_exercise=exercise({#1})> %
!endgroup!end<Lexercise>%
>
!endgroup
@@ -1245,14 +1404,14 @@
\catcode`\^^I=12
\catcode`\^^J=12\catcode`\^^M=12\catcode`\\=11\endlinechar-1}
-\def\exsh@start@Lexercise{%
- \exsh@lua@catcodesBG\exsh@start@Lexercise@}
-
\newenvironment{Lexercise}{%
- \exsh@start@Lexercise%
+ \exsh@lua@catcodesBG\exsh@start@Lexercise%
}{%
- \directlua{tex.print(exsh_cur_exercise)}
+ \ifluatex
+ \exsh@dlua{exsh_texprintlines(exsh_cur_exercise)}%
+ \else
+ Lexercise needs Lua\LaTeX!
+ \fi
}
-\directlua{dofile("exsh_lexercise.lua")}
-\fi
+\exsh@dlua{dofile("exsh_lexercise.lua")}