1

Please I want to modify the following code to get for example a red circle (fill=red!10) for the correct choice.

\documentclass{article}
\usepackage{tikz,enumerate}

\makeatother
\def\mycirc\csname#1\endcsname{%
\begin{tikzpicture}[baseline=(C.base)]
\node[draw,circle,inner sep=2pt, font=\bf](C) {\csname #1\endcsname};
\end{tikzpicture}}
\makeatletter

\begin{document}

Which of the following is {\bf true}:
\begin{enumerate}[\mycirc A] 
\item 1+1=11
\item 1-1= 2
\item 1+1=1
\item 1-1+1=1
\end{enumerate}


\end{document}
  • The choice for \bf is definitely wrong ;-) -- Who chooses the answer? You? – user31729 May 15 '16 at 18:00
  • You don't need a \makeatletter.... pair (and if you would need it, then the other way round ;-))) – user31729 May 15 '16 at 18:17
3

Something like a \ifiscorrect conditional that acts for a filled circle or a non-filled on.

Say \iscorrecttrue for the correct answer in front of the \item command.

 \documentclass{article}
 \usepackage{tikz,enumerate}

 \newif\ifiscorrect


 \def\mycirc\csname#1\endcsname{%
 \begin{tikzpicture}[baseline=(C.base)]
   \ifiscorrect
   \node[fill=red,draw,circle,inner sep=2pt, font=\bfseries](C) {\csname #1\endcsname};
   \global\iscorrectfalse
   \else
   \node[draw,circle,inner sep=2pt, font=\bfseries](C) {\csname #1\endcsname};
   \fi
 \end{tikzpicture}}




 \begin{document}

 Which of the following is \textbf{true}:
 \begin{enumerate}[\mycirc A] 
 \item 1+1=11
 \item 1-1= 2
 \item  1+1=1
 \iscorrecttrue \item 1-1+1=1
 \end{enumerate}


 \end{document}

enter image description here

A enumitem approach would be possible too, of course.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.