aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Fuhlbrück2022-01-26 19:20:16 +0100
committerFrank Fuhlbrück2022-01-26 19:20:16 +0100
commit9806c5dedd8a61daf666d35bc666c23321a359b3 (patch)
treea4b63c664f1faab87e05e821cf3265aaf77562de
parent6766e3f2cd846b770fa131664053521dbfb9171a (diff)
downloadexercisesheets-9806c5dedd8a61daf666d35bc666c23321a359b3.tar.gz
exercisesheets-9806c5dedd8a61daf666d35bc666c23321a359b3.tar.bz2
exercisesheets-9806c5dedd8a61daf666d35bc666c23321a359b3.zip
starterd merging beamer and normal version
-rw-r--r--examples/exshexample.tex15
-rw-r--r--exercisesheets-beamer.sty212
-rw-r--r--exercisesheets.sty203
-rw-r--r--exsh_lexercise.lua7
4 files changed, 366 insertions, 71 deletions
diff --git a/examples/exshexample.tex b/examples/exshexample.tex
index acd3874..5f44a02 100644
--- a/examples/exshexample.tex
+++ b/examples/exshexample.tex
@@ -36,6 +36,7 @@
\exshset{solutions=true,
task restate font={\color{black!60}},
+only=4
}
@@ -129,15 +130,7 @@ task restate font={\color{black!60}},
\end{beamersolution}
\end{exercise}
-% \begin{frame}[t]
-% \begin{exercise}[points={many, many}]
-% \visible<1>{Be careful using only etc.}
-% \visible<2>{The overlay specification is simply
-% ignored.}
-% \visible<3>{So all content is visible simultaneously and
-% should not contradict or break itself.}
-% \end{exercise}
-% \end{frame}
+
\begin{exercise}[points={many, many},savetasks,
main task font={\tiny},subtask font={\itshape}
@@ -180,7 +173,7 @@ task restate font={\color{black!60}},
}
},
\end{Lexercise}
-
+
\begin{Lexercise}
firstline = "Assume $e=3$.",
points="sum",
@@ -201,6 +194,8 @@ task restate font={\color{black!60}},
}
}
\end{Lexercise}
+
+
\end{sheet}
diff --git a/exercisesheets-beamer.sty b/exercisesheets-beamer.sty
index 4ba3690..990b973 100644
--- a/exercisesheets-beamer.sty
+++ b/exercisesheets-beamer.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,11 +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@beamersolution
\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
@@ -75,6 +83,33 @@
\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{}
+ \renewcommand{\frame}[1][]{}
+ \let\endframe\relax
+ \def\onslide<##1>{}
+ \def\only<##1>{}
+ \def\uncover<##1>{}
+ \def\visible<##1>{}
+ \def\invisible<##1>{}
+ \long\def\alt<##1>##2##3{##2}
+ \long\def\temporal<##1>##2##3##4{##3}
+ \def\uncover<##1>{}
+ \let\exsh@origitem\item
+ \def\exsh@ovrlitem<##1>{\exsh@origitem}
+ \def\item{\@ifnextchar<\exsh@ovrlitem\exsh@origitem}
+ \let\exsh@origitemize\itemize
+ \def\exsh@ovrlitemize[##1]{\exsh@origitemize}
+ \def\itemize{\@ifnextchar[\exsh@ovrlitemize\exsh@origitemize}
+ \let\exsh@origenumerate\enumerate
+ \def\exsh@ovrlenumerate[##1]{\exsh@origenumerate}
+ \def\enumerate{\@ifnextchar[\exsh@ovrlenumerate\exsh@origenumerate}
+\fi
\exsh@beamercompatdonetrue
\fi
}
@@ -97,21 +132,6 @@
number within sheet/.default=true,
forcesample/.is if=exsh@forcesample,
forcesample/.default=true,
- filenameasexercisename/.is if=exsh@filenameasexercisename,
- filenameasexercisename/.default=true,
- 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,
- beamercompatibility/.default={ignore},
- beamercompatibility/.initial={ignore},
- beamercompatibility/.code={\exsh@beamercompatibility},
gradingguides/.is if=exsh@gradingguides,
gradingguides/.default=true,
only/.initial={-},
@@ -128,18 +148,55 @@
sample/.default=true,
showtodos/.is if=exsh@showtodos,
showtodos/.default=true,
+ filenameasexercisename/.is if=exsh@filenameasexercisename,
+ filenameasexercisename/.default=true,
pointsfloatright/.is if=exsh@pointsfloatright,
pointsfloatright/.default=true,
abbrev/.is if=exsh@abbrev,
abbrev/.default=true,
+ 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},
+ beamersolution/.initial={ignore},
+ defersolutiontitle/.default={ignore},
+ defersolutiontitle/.initial={ignore},
+ framed/.default={ignore},
+ framed/.initial={ignore},
+ framed/.code={\let\newframe\relax},
+}
+\fi
-\providecommand{\@subject}{}
% 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-beamer}{No \string\subject\space given}}}
@@ -194,11 +251,6 @@
% additional exercise info
name/.initial={},
forcesample/.initial={false},
- beamersolution/.initial={false},
- beamerwithheadline/.initial={false},
- beameruseblocks/.initial={false},
- defersolutiontitle/.initial={false},
- framed/.initial={false},
firstline/.initial={},
points/.initial={},
oral/.style={/exsh/points=oral},oral/.value forbidden,
@@ -220,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={},
@@ -360,12 +419,14 @@
% 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{%
@@ -573,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}{%
@@ -581,8 +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
@@ -663,6 +728,7 @@
\exsh@skipstuff
}
+\ifexsh@beamer
\def\exsh@sheethead{%
\pgfkeysgetvalue{/exsh/title}{\exsh@tmp}%
\ifexsh@solutions
@@ -705,6 +771,54 @@
% \stepcounter{page}%
\end{frame}
}
+\else
+\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}%
+ \part[\pgfkeysvalueof{/exsh/title}]{\normalsize
+ \pgfkeysvalueof{/exsh/sheet header font}\centering%
+ \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}}\\
+ \vskip\pgfkeysvalueof{/exsh/above sheet title skip}\relax%
+ \endgroup
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet title font}\exsh@tmp\\\unskip
+ \endgroup
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet header font}%
+ \ifexsh@solutions%
+ \ifdefvoid{\exsh@solutionsby}{}{%
+ \begingroup
+ \pgfkeysvalueof{/exsh/solutionsby font}%
+ \vskip\pgfkeysvalueof{/exsh/above solutionsby skip}\relax
+ \pgfkeysvalueof{/exsh/strings/solutionsby}~\exsh@solutionsby\\\unskip%
+ \endgroup
+ }%
+ \else
+ \fi
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/note}}}{%
+ }{%
+ \ifbool{exsh@samplesolutions}{}{%
+ \begingroup
+ \pgfkeysvalueof{/exsh/sheet note font}%
+ \vskip\pgfkeysvalueof{/exsh/above sheet note skip}\relax
+ \pgfkeysvalueof{/exsh/note}\\\unskip%
+ \endgroup
+ }%
+ }%
+ \endgroup
+ }%
+ \unskip
+ \vskip\pgfkeysvalueof{/exsh/below sheet header skip}\relax
+ \stepcounter{page}%
+}
+\fi
\ifdef{\othersectionslevelsformat}{%
\renewcommand{\othersectionlevelsformat}[1]{%
@@ -850,9 +964,11 @@
}%
}%
\fi
- \clearpage
+ \ifexsh@beamer\clearpage\fi
}
\newcommand{\exsh@label}[2]{#1{#2}\leavevmode\ignorespaces}
+
+\ifexsh@beamer
\newcommand{\exsh@startsection}[2][]{%
\newpage
% \begin{block}{}
@@ -884,6 +1000,15 @@
}
\fi
}%
+\else
+\newcommand{\exsh@startsection}[2][]{%
+ \@startsection{section}{1}{\z@}%
+ {\pgfkeysvalueof{/exsh/above exercise skip}}%
+ {1em}% afterskip corrected below
+ {\pgfkeysvalueof{/exsh/exercise title font}}%
+ [#1]{#2}%
+}%
+\fi
\exshset{includeoverride/.style={}}
@@ -1025,6 +1150,13 @@
}{%
\unskip)%
}
+
+
+\ifexsh@beamer
+ \let\exsh@postsolutionclear\clearpage
+\else
+ \let\exsh@postsolutionclear\par
+\fi
\providecommand{\solution}{}
\renewenvironment{solution}[1][]{%
\pgfkeys{exsh,every solution,#1,solution font}%
@@ -1051,15 +1183,13 @@
}{}%
\next
}{%
-% \ifbool{exsh@framed}{\end{frame}}{}
\ifbool{exsh@beamersolution}{}{%
\ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
- \ifbool{exsh@oralsolutions}{\clearpage}{}%
+ \ifbool{exsh@oralsolutions}{\exsh@postsolutionclear}{}%
}{%
- \ifbool{exsh@nonoralsolutions}{\clearpage}{}%
+ \ifbool{exsh@nonoralsolutions}{\exsh@postsolutionclear}{}%
}%
}%
-% \fi
}
\def\exsh@solutiontitle#1{
@@ -1352,7 +1482,10 @@
\ifluatex
-\usepackage{luacode}
+ \let\exsh@dlua\directlua
+\else
+ \def\exsh@dlua#1{}
+\fi
%change only some catcodes to
\begingroup
@@ -1366,8 +1499,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
@@ -1389,14 +1522,15 @@
\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{tex.print(exsh_cur_exercise)}%
+ \else
+ Lexercise needs Lua\LaTeX!
+ \fi
}
-\directlua{dofile("lexercise.lua")}
-\fi
+\exsh@dlua{dofile("exsh_lexercise.lua")}
+
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")}
diff --git a/exsh_lexercise.lua b/exsh_lexercise.lua
index 5f7cdae..ed793d9 100644
--- a/exsh_lexercise.lua
+++ b/exsh_lexercise.lua
@@ -1,3 +1,10 @@
+exsh_texprintlines = function(s)
+ for line in s:gmatch("[^\n]+") do
+ tex.print(line)
+ end
+end
+
+
solution = function(sol)
if type(sol) ~= "string" then
local solt = sol