Exam Klasse: Korrekte Antwort mit einem Pfeil markieren

Fragen und Probleme, die nicht den obigen Kategorien zugeordnet werden können


Gast

Exam Klasse: Korrekte Antwort mit einem Pfeil markieren

Beitrag von Gast »

Guten Tag,

hat jemand eine Idee, wie man in der "exam"-Klasse die korrekte Antwort (also \correctchoice) vor dem Buchstaben mit einem Pfeil markieren kann, sodass das Ergebnis dan etwa so aussieht:

A Falsche Antwort
--> B Richtige Antwort
C Falsche Antwort
D Falsche Antwort
E Falsche Antwort[/d]

Bartman
Forum-Meister
Forum-Meister
Beiträge: 2456
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Beitrag von Bartman »

Ein fehlendes Minimalbeispiel wirkt auf die Helfer nicht sehr motivierend. Dessen Anfertigung wäre in diesem Fall nicht aufwendig gewesen.

Mit der Änderung der Kopie der Definition der choices-Umgebung aus der Datei exam.cls muss der Befehl \CorrectChoice nicht ersetzt werden. Die Befehle für das Einfügen des Pfeils habe ich einer Antwort von Paul Gaborit entnommen.
\documentclass[answers]{exam}

\makeatletter
\renewenvironment{choices}%
  {\list{\choicelabel}%
     {\usecounter{choice}\def\makelabel##1{\hss\llap{##1}}%
       \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}%
       \def\choice{%
         \if@correctchoice
           \color@endgroup
           \endgroup
         \fi
         \item
         \do@choice@pageinfo
       } % choice
       \def\CorrectChoice{%
         \if@correctchoice
           \color@endgroup
           \endgroup
         \fi
         \ifprintanswers
           % We can't say \choice here, because that would
           % insert an \endgroup:
           % 2016/05/10: We say \color@begingroup in addition to
           % \begingroup in case \CorrectChoiceEmphasis involves color
           % and the text exactly fills the line (which would
           % otherwise create a blank line after this choice):
           % 2016/05/11: We leave hmode if we're in it,
           % i.e., if there's no blank line preceding this
           % \CorrectChoice command.  (Without this, the
           % \special created by a \color{whatever} command that might
           % be inserted by \CorrectChoice@Emphasis would be appended 
           % to the previous \choice, which could cause an extra
           % (blank) line to be inserted before this \CorrectChoice.)
           % Since \par and \endgraf seem to cancel \@totalleftmargin
           % (for reasons I don't understand), we'll do the following:
           % Motivated by  the def of \leavevmode, 
           %      \def\leavevmode{\unhbox\voidb@x}
           % we will now leave hmode (if we're in hmode):
           \ifhmode \unskip\unskip\unvbox\voidb@x \fi
           \begingroup \color@begingroup \@correctchoicetrue
           \CorrectChoice@Emphasis
         \fi
         \item\mbox{}\llap{$\rightarrow$\hspace{2em}}% <- eingefügt
         \do@choice@pageinfo
       } % CorrectChoice
       \let\correctchoice\CorrectChoice
       \labelwidth\leftmargin\advance\labelwidth-\labelsep
       \topsep=0pt
       \partopsep=0pt
       \choiceshook
     }%
  }%
  {\if@correctchoice \color@endgroup \endgroup \fi \endlist}
\makeatother

%\CorrectChoiceEmphasis{}

\begin{document}
\begin{questions}
\question Frage?

\begin{choices}
\choice Falsche Antwort
\CorrectChoice Richtige Antwort
\choice Falsche Antwort
\choice Falsche Antwort
\choice Falsche Antwort
\end{choices}
\end{questions}
\end{document}
Der Kommentar am Ende der ergänzten Befehlsfolge dient nicht nur dem Einfügen meiner Bemerkung.

Gast

Beitrag von Gast »

Genau so habe ich mir das vorgestellt. Ganz herzlichen Dank. Top!

Antworten