]> git.sthu.org Git - exsheet.git/commitdiff
Add coloranswers option to exsheet2 main
authorStefan Huber <shuber@sthu.org>
Wed, 21 Oct 2026 06:25:53 +0000 (08:25 +0200)
committerStefan Huber <shuber@sthu.org>
Wed, 21 Oct 2026 06:25:53 +0000 (08:25 +0200)
With the new class option coloranswers, answers shown via showanswers are
typeset in color, gray by default. The color can be changed with
\answercolor{...}. Without the option, the output is unchanged and xcolor
is not loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README.markdown
exsheet2.cls

index f5d8c6ef9a2499bbc60110fe3517000ba5d72d38..defe3d64cefe52df1d21e37946609fad8523c26c 100644 (file)
@@ -47,6 +47,10 @@ formulieren. Man kann auch die Antwort mitformulieren und über die Option
 \end{answer}
 ```
 
 \end{answer}
 ```
 
+Mit der zusätzlichen Option `coloranswers` werden die Antworten farbig
+gesetzt, standardmäßig grau. Die Farbe lässt sich mit `\answercolor{...}`
+ändern, z.B. `\answercolor{blue!70!black}`. Die Option lädt `xcolor`.
+
 Ein optionales Argument erlaubt es die Punkteanzahl bekanntzugeben. Die
 Umgebung `choices` erlaubt es single- oder multiple-choice Fragen zu
 formulieren:
 Ein optionales Argument erlaubt es die Punkteanzahl bekanntzugeben. Die
 Umgebung `choices` erlaubt es single- oder multiple-choice Fragen zu
 formulieren:
index 833bb6a3f4351d8b2efbb2244a09128512da2265..04914db7a2e385c139223d92e4af8238d4ea9fdb 100644 (file)
@@ -12,6 +12,7 @@
 \DeclareOption{austrian}{\def \exsheetgerman{}}
 \DeclareOption{naustrian}{\def \exsheetgerman{}}
 \DeclareOption{showanswers}{\def \exsheetshowanswers{}}
 \DeclareOption{austrian}{\def \exsheetgerman{}}
 \DeclareOption{naustrian}{\def \exsheetgerman{}}
 \DeclareOption{showanswers}{\def \exsheetshowanswers{}}
+\DeclareOption{coloranswers}{\def \exsheetcoloranswers{}}
 \DeclareOption{exam}{\def \exsheetexam{}}
 \DeclareOption{nostudentinfo}{\def \exsheetnostudentinfo{}}
 \DeclareOption{nogradeinfo}{\def \exsheetnogradeinfo{}}
 \DeclareOption{exam}{\def \exsheetexam{}}
 \DeclareOption{nostudentinfo}{\def \exsheetnostudentinfo{}}
 \DeclareOption{nogradeinfo}{\def \exsheetnogradeinfo{}}
   \newline}
 {}
 
   \newline}
 {}
 
+% Color of answers, only effective with option coloranswers.
+\def\exsheet@answercolor{gray}
+\newcommand{\answercolor}[1]{\def\exsheet@answercolor{#1}}
+
+\@ifundefined{exsheetcoloranswers}{}{\RequirePackage{xcolor}}
+
 \@ifundefined{exsheetshowanswers}{
   \excludecomment{answer}
 }{
 \@ifundefined{exsheetshowanswers}{
   \excludecomment{answer}
 }{
-  \newenvironment{answer}{\vspace*{0.5em}\textit{\theanswer:} \hspace*{0.5em} }{}
+  \newenvironment{answer}{%
+    \vspace*{0.5em}%
+    \@ifundefined{exsheetcoloranswers}{}{\color{\exsheet@answercolor}}%
+    \textit{\theanswer:} \hspace*{0.5em} }{}
 }
 
 \newenvironment{choices}{%
 }
 
 \newenvironment{choices}{%