From 480b75f8d24b14a94af33179883692805e7302af Mon Sep 17 00:00:00 2001 From: Frank Fuhlbrück Date: Wed, 25 Feb 2015 11:09:18 +0000 Subject: exercisesheets.sty with new features --- exercisesheets.sty | 133 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 114 insertions(+), 19 deletions(-) (limited to 'exercisesheets.sty') diff --git a/exercisesheets.sty b/exercisesheets.sty index 730b53d..0a53683 100644 --- a/exercisesheets.sty +++ b/exercisesheets.sty @@ -16,6 +16,7 @@ \RequirePackage{kvoptions} \RequirePackage{ifthen} +\RequirePackage{ifluatex} \RequirePackage{amsmath} @@ -24,6 +25,11 @@ \newif\ifexsh@solutions \newif\ifexsh@oralsolutions \newif\ifexsh@nonoralsolutions +\newif\ifexsh@inplace +\newif\ifexsh@pointsfloatright +\newif\ifexsh@bonus +\newif\ifexsh@abbrev + \pgfkeys{/exsh/.is family,/exsh, solutions/.is choice, solutions/true/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionstrue, @@ -34,6 +40,14 @@ only/.initial={-}, all/.style={/exsh/only={-}},all/.value forbidden, solutionsby/.code={\def\exsh@solutionsby{#1}},solutionsby/.value required, + bonus/.is if=exsh@bonus, + bonus/.default=true, + inplace/.is if=exsh@inplace, + inplace/.default=true, + pointsfloatright/.is if=exsh@pointsfloatright, + pointsfloatright/.default=true, + abbrev/.is if=exsh@abbrev, + abbrev/.default=true, } % store title data for sheet headers @@ -85,10 +99,19 @@ firstline/.initial={}, points/.initial={}, oral/.style={/exsh/points=oral},oral/.value forbidden, - bonus/.style={/exsh/strings/points=\pgfkeysvalueof{/exsh/strings/bonus points}, - /exsh/strings/point=\pgfkeysvalueof{/exsh/strings/bonus point}}, + inplace/.initial={false}, + pointsfloatright/.initial={false}, + bonus/.initial={false}, + nobonus/.style={/exsh/bonus=false},nobonus/.value forbidden, + abbrev/.initial={false}, + noabbrev/.style={/exsh/abbrev=false},noabbrev/.value forbidden, pointsinfo/.initial={}, - optional/.style={/exsh/pointsinfo=\pgfkeysvalueof{/exsh/strings/optional}},optional/.value forbidden, + optional/.style={/exsh/pointsinfo=\ifexsh@abbrev% + \pgfkeysvalueof{/exsh/strings/optional abbrev}% + \else% + \pgfkeysvalueof{/exsh/strings/optional}% + \fi}, + optional/.value forbidden, exercisemark/.initial={}, difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden, % @@ -103,11 +126,15 @@ strings/hint/.initial={}, strings/remark/.initial={}, strings/oral/.initial={}, + strings/oral abbrev/.initial={}, strings/point/.initial={}, strings/points/.initial={}, + strings/points abbrev/.initial={}, strings/bonus point/.initial={}, strings/bonus points/.initial={}, + strings/bonus points abbrev/.initial={}, strings/optional/.initial={}, + strings/optional abbrev/.initial={}, % % languages: predifined string sets language/.is choice, @@ -122,11 +149,15 @@ \exsh@deforprovide{/exsh/strings/hint} {Hinweis}% \exsh@deforprovide{/exsh/strings/remark} {Bemerkung}% \exsh@deforprovide{/exsh/strings/oral} {m\"undlich}% + \exsh@deforprovide{/exsh/strings/oral abbrev} {mdl.}% \exsh@deforprovide{/exsh/strings/point} {Punkt}% \exsh@deforprovide{/exsh/strings/points} {Punkte}% + \exsh@deforprovide{/exsh/strings/points abbrev}{P.}% \exsh@deforprovide{/exsh/strings/bonus point} {Zusatzpunkt}% \exsh@deforprovide{/exsh/strings/bonus points}{Zusatzpunkte}% + \exsh@deforprovide{/exsh/strings/bonus points abbrev}{ZP.}% \exsh@deforprovide{/exsh/strings/optional} {optional}% + \exsh@deforprovide{/exsh/strings/optional abbrev} {opt.}% },language/german/.value forbidden, language/ngerman/.style={/exsh/language/german=#1}, language/english/.code={% @@ -140,11 +171,15 @@ \exsh@deforprovide{/exsh/strings/hint} {Hint}% \exsh@deforprovide{/exsh/strings/remark} {Remark}% \exsh@deforprovide{/exsh/strings/oral} {oral}% + \exsh@deforprovide{/exsh/strings/oral abbrev} {oral}% \exsh@deforprovide{/exsh/strings/point} {point}% \exsh@deforprovide{/exsh/strings/points} {points}% + \exsh@deforprovide{/exsh/strings/points abbrev}{p.}% \exsh@deforprovide{/exsh/strings/bonus point} {bonus point}% \exsh@deforprovide{/exsh/strings/bonus points}{bonus points}% + \exsh@deforprovide{/exsh/strings/bonus points abbrev}{b.p.}% \exsh@deforprovide{/exsh/strings/optional} {optional}% + \exsh@deforprovide{/exsh/strings/optional abbrev} {opt.}% },language/english/.value forbidden, language/.unknown/.code={% \PackageWarning{exercisesheets}{Unknown language \pgfkeyscurrentname. @@ -502,14 +537,34 @@ \edef\exsh@points{\pgfkeysvalueof{/exsh/pointsinfo}}% }{% \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{% - \edef\exsh@points{\pgfkeysvalueof{/exsh/strings/oral}}% + \ifexsh@abbrev% + \edef\exsh@points{\pgfkeysvalueof{/exsh/strings/oral abbrev}}% + \else% + \edef\exsh@points{\pgfkeysvalueof{/exsh/strings/oral}}% + \fi% }{% - \ifthenelse{\equal{1}{\pgfkeysvalueof{/exsh/points}}}{% - \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/point}}% - }{% - \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points}}% - }% - }% + \ifexsh@abbrev% + \ifexsh@bonus% + \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/bonus points abbrev}}% + \else% + \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points abbrev}}% + \fi% + \else% + \ifthenelse{\equal{1}{\pgfkeysvalueof{/exsh/points}}}{% + \ifexsh@bonus% + \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/bonus point}}% + \else% + \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/point}}% + \fi% + }{% + \ifexsh@bonus% + \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/bonus points}}% + \else% + \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points}}% + \fi% + }% + \fi% + }% \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/pointsinfo}}}{}{% \edef\exsh@points{\expandonce\exsh@points, \pgfkeysvalueof{/exsh/pointsinfo}}% }% @@ -635,7 +690,7 @@ } \newcommand{\points}[2][]{% \ifthenelse{\equal{}{#2}}{}{\exshset{points=#2}}% - \bgroup + \bgroup% \exshset{#1}% \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/pointsinfo}}}{% \def\exsh@tmp{}% @@ -643,24 +698,64 @@ \def\exsh@tmp{, \pgfkeysvalueof{/exsh/pointsinfo}}% }% \ifthenelse{\equal{#2}{oral}}{% - \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral}\exsh@tmp}% + \ifexsh@abbrev% + \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral abbrev}\exsh@tmp}% + \else% + \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral}\exsh@tmp}% + \fi% }{% \ifthenelse{\equal{#2}{}}{% \exsh@subexpoints{\pgfkeysvalueof{/exsh/pointsinfo}}% }{% - \ifthenelse{\equal{#2}{1}}{% - \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/point}\exsh@tmp}% - }{% - \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points}\exsh@tmp}% - }% + \ifexsh@abbrev% + \ifexsh@bonus% + \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/bonus points abbrev}\exsh@tmp}% + \else% + \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points abbrev}\exsh@tmp}% + \fi% + \else% + \ifthenelse{\equal{#2}{1}}{% + \ifexsh@bonus% + \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/bonus point}\exsh@tmp}% + \else% + \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/point}\exsh@tmp}% + \fi% + }{% + \ifexsh@bonus% + \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/bonus points}\exsh@tmp}% + \else% + \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points}\exsh@tmp}% + \fi% + }% + \fi }% }% \egroup \ignorespaces } + +\ifluatex% +\def\exsh@putatend#1{% +\leavevmode\luatextextdir TRT\unskip{\luatextextdir TLT{\hfill~~#1}}\luatextextdir TLT}% +\else% +\def\exsh@putatend#1{% +\TeXXeTstate=1% +\beginR\unskip{\beginL~~#1\endL}\hfill\beginL\TeXXeTstate=0}% +\fi + +\def\exsh@leaveinplace#1{\unskip~{#1} } +\def\exsh@insertFill#1{\unskip\nobreak\space\nobreak\hspace*{\fill}\allowbreak\hspace*{\fill}{#1}\unskip} + \newcommand{\exsh@subexpoints}[1]{% - \unskip\nobreak\space\nobreak\hspace*{\fill}\allowbreak\hspace*{\fill}% - {\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}% + \ifexsh@inplace% + \exsh@leaveinplace{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}% + \else% + \ifexsh@pointsfloatright% can be used directly after \item etc. + \exsh@putatend{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}% + \else% original points macro with fill + \exsh@insertFill{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}% + \fi% + \fi% } \newcommand{\TODO}{% -- cgit v1.2.3