diff options
| -rw-r--r-- | examples/exshexample.tex | 17 | ||||
| -rw-r--r-- | exercisesheets.sty | 11 | ||||
| -rw-r--r-- | exsh_lexercise.lua | 19 |
3 files changed, 45 insertions, 2 deletions
diff --git a/examples/exshexample.tex b/examples/exshexample.tex index 9d507b5..85b726a 100644 --- a/examples/exshexample.tex +++ b/examples/exshexample.tex @@ -77,6 +77,23 @@ only={-} \begin{exercise}[points={many, many}, firstline={Read the manual.}] \end{exercise} + \begin{solution}[framed,fragile] + Oh no, it's quite long. + \newframe + Really long, but please \verb|\relax|. + Ok, but my brain feels like: + \begin{verbatim} +% + x + $ t +& + + +\ +# + \end{verbatim} + And yours? + \end{solution} \end{sheet} %3 diff --git a/exercisesheets.sty b/exercisesheets.sty index 501251a..6616f9a 100644 --- a/exercisesheets.sty +++ b/exercisesheets.sty @@ -194,6 +194,8 @@ framed/.default={ignore}, framed/.initial={ignore}, framed/.code={\let\newframe\relax}, + fragile/.default={ignore}, + fragile/.initial={ignore}, } \fi %%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1319,6 +1321,10 @@ } } \newcommand{\solutiontitle}[1][\linewidth]{ + \ifhmode \linebreak\fi\exsh@solutiontitle{#1} +} + +\newcommand{\deferredsolutiontitle}[1][\linewidth]{ \ifbool{exsh@defersolutiontitle}{% \ifhmode \linebreak\fi\exsh@solutiontitle{#1} }{}% @@ -1654,8 +1660,9 @@ !exsh@dlua<exsh_texprintlines(exsh_cur_exercise)>% > !global!long!def!exsh@start@lframed#1\end{solution}< % - !exsh@dlua<exsh_cur_solution=[[#1]]> % + !exsh@dlua<exsh_cur_solution=fragileframed([[#1]])> % !endgroup!end<solution>% + !exsh@dlua<exsh_texprintlines(exsh_cur_solution)>% > !endgroup @@ -1673,6 +1680,8 @@ \catcode`\~=12 \catcode`\@=11 \catcode`\%=12 +\catcode`\ =12 +\catcode9=12 \catcode`\^^I=12 \catcode`\^^J=12\catcode`\^^M=12\catcode`\\=11\endlinechar-1} diff --git a/exsh_lexercise.lua b/exsh_lexercise.lua index b05d29e..85a298b 100644 --- a/exsh_lexercise.lua +++ b/exsh_lexercise.lua @@ -1,5 +1,5 @@ exsh_texprintlines = function(s) - for line in s:gmatch("[^\n]+") do + for line in s:gmatch("[^\n]*") do tex.print(line) end end @@ -117,3 +117,20 @@ exercise = function(ex) return ece end +fragileframed = function(s) + local frames,p,pn,n,i = {},1,1,#s,0 + pn = s:find([[\newframe]],p) or n+1 + while p < n do + i = i+1 + frames[i] = [[ + \begin{frame}[t,fragile] + \solutiontitle[\textwidth] + ]] .. s:sub(p,pn-1) .. [[ + \end{frame} + ]] + p = pn + 9 + pn = s:find([[\newframe]],p) or n+1 + end + return table.concat(frames,"") +end + |
