aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exercisesheets.sty112
-rw-r--r--exercisesheets.tex26
2 files changed, 91 insertions, 47 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty
index 7b3b5e6..22d2488 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -84,6 +84,10 @@
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}},
+ pointsinfo/.initial={},
+ optional/.style={/exsh/pointsinfo=\pgfkeysvalueof{/exsh/strings/optional}},optional/.value forbidden,
%
% translatable strings
strings/sheet/.initial={},
@@ -98,37 +102,46 @@
strings/oral/.initial={},
strings/point/.initial={},
strings/points/.initial={},
+ strings/bonus point/.initial={},
+ strings/bonus points/.initial={},
+ strings/optional/.initial={},
%
% languages: predifined string sets
language/.is choice,
language/german/.code={%
- \exsh@deforprovide{/exsh/strings/sheet} {\"Ubungsblatt}%
- \exsh@deforprovide{/exsh/strings/sheets} {\"Ubungsbl\"atter}%
- \exsh@deforprovide{/exsh/strings/solutions} {L\"osungsvorschl\"age}%
- \exsh@deforprovide{/exsh/strings/solutionsby}{L\"osungen von}%
- \exsh@deforprovide{/exsh/strings/exercise} {Aufgabe}%
- \exsh@deforprovide{/exsh/strings/solution} {L\"osung}%
- \exsh@deforprovide{/exsh/strings/idea} {L\"osungsidee}%
- \exsh@deforprovide{/exsh/strings/hint} {Hinweis}%
- \exsh@deforprovide{/exsh/strings/remark} {Bemerkung}%
- \exsh@deforprovide{/exsh/strings/oral} {m\"undlich}%
- \exsh@deforprovide{/exsh/strings/point} {Punkt}%
- \exsh@deforprovide{/exsh/strings/points} {Punkte}%
+ \exsh@deforprovide{/exsh/strings/sheet} {\"Ubungsblatt}%
+ \exsh@deforprovide{/exsh/strings/sheets} {\"Ubungsbl\"atter}%
+ \exsh@deforprovide{/exsh/strings/solutions} {L\"osungsvorschl\"age}%
+ \exsh@deforprovide{/exsh/strings/solutionsby} {L\"osungen von}%
+ \exsh@deforprovide{/exsh/strings/exercise} {Aufgabe}%
+ \exsh@deforprovide{/exsh/strings/solution} {L\"osung}%
+ \exsh@deforprovide{/exsh/strings/idea} {L\"osungsidee}%
+ \exsh@deforprovide{/exsh/strings/hint} {Hinweis}%
+ \exsh@deforprovide{/exsh/strings/remark} {Bemerkung}%
+ \exsh@deforprovide{/exsh/strings/oral} {m\"undlich}%
+ \exsh@deforprovide{/exsh/strings/point} {Punkt}%
+ \exsh@deforprovide{/exsh/strings/points} {Punkte}%
+ \exsh@deforprovide{/exsh/strings/bonus point} {Zusatzpunkt}%
+ \exsh@deforprovide{/exsh/strings/bonus points}{Zusatzpunkte}%
+ \exsh@deforprovide{/exsh/strings/optional} {optional}%
},language/german/.value forbidden,
language/ngerman/.style={/exsh/language/german=#1},
language/english/.code={%
- \exsh@deforprovide{/exsh/strings/sheet} {Exercise Sheet}%
- \exsh@deforprovide{/exsh/strings/sheets} {Exercise Sheets}%
- \exsh@deforprovide{/exsh/strings/solutions} {Suggested Solutions}%
- \exsh@deforprovide{/exsh/strings/solutionsby}{Solutions by}%
- \exsh@deforprovide{/exsh/strings/exercise} {Exercise}%
- \exsh@deforprovide{/exsh/strings/solution} {Solution}%
- \exsh@deforprovide{/exsh/strings/idea} {Idea for solution}%
- \exsh@deforprovide{/exsh/strings/hint} {Hint}%
- \exsh@deforprovide{/exsh/strings/remark} {Remark}%
- \exsh@deforprovide{/exsh/strings/oral} {oral}%
- \exsh@deforprovide{/exsh/strings/point} {point}%
- \exsh@deforprovide{/exsh/strings/points} {points}%
+ \exsh@deforprovide{/exsh/strings/sheet} {Exercise Sheet}%
+ \exsh@deforprovide{/exsh/strings/sheets} {Exercise Sheets}%
+ \exsh@deforprovide{/exsh/strings/solutions} {Suggested Solutions}%
+ \exsh@deforprovide{/exsh/strings/solutionsby} {Solutions by}%
+ \exsh@deforprovide{/exsh/strings/exercise} {Exercise}%
+ \exsh@deforprovide{/exsh/strings/solution} {Solution}%
+ \exsh@deforprovide{/exsh/strings/idea} {Idea for solution}%
+ \exsh@deforprovide{/exsh/strings/hint} {Hint}%
+ \exsh@deforprovide{/exsh/strings/remark} {Remark}%
+ \exsh@deforprovide{/exsh/strings/oral} {oral}%
+ \exsh@deforprovide{/exsh/strings/point} {point}%
+ \exsh@deforprovide{/exsh/strings/points} {points}%
+ \exsh@deforprovide{/exsh/strings/bonus point} {bonus point}%
+ \exsh@deforprovide{/exsh/strings/bonus points}{bonus points}%
+ \exsh@deforprovide{/exsh/strings/optional} {optional}%
},language/english/.value forbidden,
language/.unknown/.code={%
\PackageWarning{exercisesheets}{Unknown language \pgfkeyscurrentname.
@@ -464,16 +477,27 @@
\def\exsh@points{}%
\def\exsh@shortpoints{}%
}{%
- \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
- \edef\exsh@points{\pgfkeysvalueof{/exsh/strings/oral}}%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/points}}}{%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/pointsinfo}}%
}{%
- \ifthenelse{\equal{1}{\pgfkeysvalueof{/exsh/points}}}{%
- \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/point}}%
+ \ifthenelse{\equal{oral}{\pgfkeysvalueof{/exsh/points}}}{%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/strings/oral}}%
}{%
- \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points}}%
+ \ifthenelse{\equal{1}{\pgfkeysvalueof{/exsh/points}}}{%
+ \edef\exsh@points{1 \pgfkeysvalueof{/exsh/strings/point}}%
+ }{%
+ \edef\exsh@points{\pgfkeysvalueof{/exsh/points} \pgfkeysvalueof{/exsh/strings/points}}%
+ }%
+ }%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/pointsinfo}}}{}{%
+ \edef\exsh@points{\expandonce\exsh@points, \pgfkeysvalueof{/exsh/pointsinfo}}%
}%
}%
- \edef\exsh@shortpoints{ (\expandonce\exsh@points)}%
+ \ifthenelse{\equal{}{\exsh@points}}{%
+ \def\exsh@shortpoints{}%
+ }{%
+ \edef\exsh@shortpoints{ (\expandonce\exsh@points)}%
+ }%
\preto\exsh@points{\enskip\hfill\bgroup%
\pgfkeysvalueof{/exsh/points font}}%
\appto\exsh@points{\egroup}%
@@ -574,19 +598,31 @@
\PackageWarning{exercisesheets}{Obsolete \string\pun[] macro used. Please use
something\MessageBreak like \string\points{10} or \string\points{oral} instead.}{}%
\exsh@subexpoints{#1}%
-} \newcommand{\points}[1]{%
- \ifthenelse{\equal{#1}{oral}}{%
+}
+\newcommand{\points}[2][]{%
+ \exshset{pointsinfo={},#1}%
+ \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/pointsinfo}}}{%
+ \def\exsh@tmp{}%
+ }{%
+ \def\exsh@tmp{, \pgfkeysvalueof{/exsh/pointsinfo}}%
+ }%
+ \ifthenelse{\equal{#2}{oral}}{%
\exshset{oral}%
- \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral}}%
+ \exsh@subexpoints{\pgfkeysvalueof{/exsh/strings/oral}\exsh@tmp}%
}{%
- \exshset{points=#1}%
- \ifthenelse{\equal{#1}{1}}{%
- \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/point}}%
+ \exshset{points=#2}%
+ \ifthenelse{\equal{#2}{}}{%
+ \exsh@subexpoints{\pgfkeysvalueof{/exsh/pointsinfo}}%
}{%
- \exsh@subexpoints{#1~\pgfkeysvalueof{/exsh/strings/points}}%
+ \ifthenelse{\equal{#2}{1}}{%
+ \exsh@subexpoints{1~\pgfkeysvalueof{/exsh/strings/point}\exsh@tmp}%
+ }{%
+ \exsh@subexpoints{#2~\pgfkeysvalueof{/exsh/strings/points}\exsh@tmp}%
+ }%
}%
}%
-} \newcommand{\exsh@subexpoints}[1]{%
+}
+\newcommand{\exsh@subexpoints}[1]{%
\unskip\nobreak\space\nobreak\hspace*{\fill}\allowbreak\hspace*{\fill}%
{\pgfkeysvalueof{/exsh/points font}\mbox{(#1)}}%
}
diff --git a/exercisesheets.tex b/exercisesheets.tex
index 46888cb..81dec8f 100644
--- a/exercisesheets.tex
+++ b/exercisesheets.tex
@@ -29,7 +29,7 @@
\newcommand{\exsh}{\texttt{exercisesheets}\xspace}
-\newcommand{\param}[1]{$\langle${\normalfont\itshape #1}$\rangle$}
+\newcommand{\param}[1]{$\langle${\normalfont\itshape #1\/}$\rangle$}
\newcommand{\opt}[1]{\textcolor{green!50!black}{#1}}
\newcommand{\option}[1]{{\normalfont\texttt{\color{blue!50!black}#1}}}
@@ -133,7 +133,7 @@ The following options are available:
\subsection{Supplying Meta-Data}
The following commands are enhanced (or provided) to set the options controlling
-the sheet headers (see Section \ref{sec:sheet}):
+the sheet headers (see Section~\ref{sec:sheet}):
\begin{lstlisting}
\subject{(*\param{subject}*)}
\author{(*\param{author}*)}
@@ -200,14 +200,18 @@ The following \param{options} are supported:
This inserts an exercise into the current document. The following options are
supported:
\begin{description}
- \item[\option{points=\param{number}}] Assign this exercise \param{number}
- points. By default, exercises are unlabelled.
- \item[\option{oral}] Label this exercise as \emph{oral}. This supersedes and is
- superseded by the option \option{points}.
\item[\option{name=\param{text}}] Use \param{text} as the name of the exercise.
Useful for exercises that prove a famous theorem.
\item[\option{firstline=\param{text}}] Save some space by text \param{text}
behind the exercise title.
+ \item[\option{points=\param{number}}] Assign this exercise \param{number}
+ points. By default, exercises are unlabelled.
+ \item[\option{oral}] Label this exercise as \emph{oral}. This supersedes and is
+ superseded by the option \option{points}.
+ \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.
\item[\option{solutions\opt{=\param{true/false}}}] Use this to override the
document (or sheet) default.
\end{description}
@@ -252,8 +256,9 @@ each place.
\begin{exercise}[points=10]
\begin{enumerate}
\item Part 1 \points{oral}
- \item Part 2 \points{4}
- \item Part 3 \points{6}
+ \item Part 2 \points[optional]{oral}
+ \item Part 3 \points{4}
+ \item Part 4 \points[bonus]{6}
\end{enumerate}
\end{exercise}
\end{lstlisting}
@@ -298,6 +303,9 @@ the used strings, you can do so with the following options:
\item[\option{strings/oral=\param{string}}]
\item[\option{strings/point=\param{string}}]
\item[\option{strings/points=\param{string}}]
+ \item[\option{strings/bonus point=\param{string}}]
+ \item[\option{strings/bonus points=\param{string}}]
+ \item[\option{strings/optional=\param{string}}]
\end{description}
Example: Give an introduction that should only be included in the version with
@@ -393,7 +401,7 @@ The following options allow fine-tuning of the spacing:
Example: Only include points for sub-exercises when solutions are typeset:
\begin{lstlisting}
-\ifsolutions{}{\renewcommand{\points}[1]{}}
+\ifsolutions{}{\renewcommand{\points}[2][]{}}
\end{lstlisting}
\subsection{Using Hooks}