diff options
| -rw-r--r-- | exercisesheets.sty | 133 | ||||
| -rw-r--r-- | exercisesheets.tex | 15 |
2 files changed, 128 insertions, 20 deletions
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}{% diff --git a/exercisesheets.tex b/exercisesheets.tex index c4fcf3d..072f2a4 100644 --- a/exercisesheets.tex +++ b/exercisesheets.tex @@ -91,6 +91,7 @@ finally combined into this package. \item \texttt{pgfkeys} (part of PGF 2.0) \item \texttt{ifthen} \item \texttt{amsmath} (for \verb|\numberwithin|) + \item \texttt{iflualatex} \end{itemize} @@ -138,6 +139,10 @@ The following options are available: is not necessary, as the main document language will be automatically detected. Currently \option{english}, \option{german} and \option{ngerman} are supported. Other translations are welcome: Please contact the author. + \item[\option{pointsfloatright}] Use an alternative mechanism to place points for Sub-Exercises. + If this option is used, the points label for a Sub-Exercise is placed at the (right) end of the current line. + It is especially useful if used in a context like \texttt{$\backslash$item$\backslash$points$\{3\}$}. + This option exploits (and partially breaks) RTL-Support. \end{description} \subsection{Supplying Meta-Data} @@ -221,7 +226,10 @@ supported: \item[\option{pointsinfo=\param{text}}] Supply \param{text} as additional information to be displayed after the points. \item[\option{optional}] Shortcut for \option{pointsinfo=optional} with - automatic translation. + automatic translation and abbreviation (if requested). + \item[\option{bonus}] Change \enquote{points} to \enquote{bonus points} (with + automatic translation and abbreviation). + \item[\option{abbrev}] Use abbreviated labels. \item[\option{exercisemark=\param{symbol}}] Mark the exercise with \param{symbol} in the left margin. \item[\option{difficult}] Shortcut for \option{exercisemark=*}. @@ -273,6 +281,7 @@ each place. \item Part 3 \points{4} \item Part 4 \points[bonus]{6} \end{enumerate} + Sub-Exercises within continuous text can be annotated like this \points[inplace]{3} without adding space. \end{exercise} \end{lstlisting} @@ -314,11 +323,15 @@ the used strings, you can do so with the following options: \item[\option{strings/solution=\param{string}}] \item[\option{strings/hint=\param{string}}] \item[\option{strings/oral=\param{string}}] + \item[\option{strings/oral abbrev=\param{string}}] \item[\option{strings/point=\param{string}}] \item[\option{strings/points=\param{string}}] + \item[\option{strings/points abbrev=\param{string}}] \item[\option{strings/bonus point=\param{string}}] \item[\option{strings/bonus points=\param{string}}] + \item[\option{strings/bonus points abbrev=\param{string}}] \item[\option{strings/optional=\param{string}}] + \item[\option{strings/optional abbrev=\param{string}}] \end{description} Example: Give an introduction that should only be included in the version with |
