aboutsummaryrefslogtreecommitdiff
path: root/exercisesheets.sty
diff options
context:
space:
mode:
Diffstat (limited to 'exercisesheets.sty')
-rw-r--r--exercisesheets.sty28
1 files changed, 26 insertions, 2 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty
index 572549a..d096e54 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -64,6 +64,7 @@
\newif\ifexsh@beameruseblocks
\newif\ifexsh@defersolutiontitle
\newif\ifexsh@framed
+\newif\ifexsh@fragile
\fi
%Also only true for beamer, but we want to use it elsewhere
\newif\ifexsh@beamersolution
@@ -174,6 +175,8 @@
defersolutiontitle/.default=true,
framed/.is if=exsh@framed,
framed/.default=true,
+ fragile/.is if=exsh@fragile,
+ fragile/.default=true,
beamersolution/.initial={false},
beamerwithheadline/.initial={false},
beameruseblocks/.initial={false},
@@ -648,6 +651,8 @@
\fi
%%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%TODO: We need some proper switch-case here
+%evaluate csname/csdef+detokenize
\ExplSyntaxOn
\cs_new_eq:NN \exsh@ifsingletoken \tl_if_single_token:nTF
\ExplSyntaxOff
@@ -1293,7 +1298,19 @@
\ifhmode \linebreak\fi
\exsh@solutiontitle{\linewidth}
}%
- \ifbool{exsh@framed}{\Collect@Body\exsh@collectedframe}{}%
+ \let\next\relax
+ \ifbool{exsh@framed}{%
+ \def\next{\Collect@Body\exsh@collectedframe}%
+ \ifbool{exsh@fragile}{%
+ \ifluatex%
+ \def\next{\exsh@start@lframed@}
+ \else
+ \PackageError{exercisesheets}{Fragile frames require
+ LuaLaTeX!}{}
+ \fi%
+ }{}%
+ }{}%
+ \next%
}%
\else%--------- NON-BEAMER: ---------------------------------------
\def\exsh@startsolution{\@afterindentfalse
@@ -1561,10 +1578,15 @@
>
!global!long!def!exsh@start@skip@Lexercise#1\end{Lexercise}< %
!exsh@dlua<exsh_cur_exercise=exercise({#1})> %
+ !ifluatex!else!refstepcounter<section>!fi
!endgroup!endgroup%
!expandafter!exsh@skipstuff%
!exsh@dlua<exsh_texprintlines(exsh_cur_exercise)>%
>
+!global!long!def!exsh@start@lframed#1\end{solution}< %
+ !exsh@dlua<exsh_cur_solution=[[#1]]> %
+ !endgroup!end<solution>%
+>
!endgroup
\def\exsh@lua@catcodesBG{
@@ -1590,11 +1612,13 @@
\ifluatex
\exsh@dlua{exsh_texprintlines(exsh_cur_exercise)}%
\else
+ \refstepcounter{section}
Lexercise needs Lua\LaTeX!
\fi
}
+%TODO:setcounter without luatex
\def\exsh@skipstuff@Lexercise{\exsh@lua@catcodesBG\exsh@start@skip@Lexercise}%
-% \exsh@lua@catcodesBG\exsh@start@skip@Lexercise}
+\def\exsh@start@lframed@{\exsh@lua@catcodesBG\exsh@start@lframed}
\exsh@dlua{dofile("exsh_lexercise.lua")}