I am trying to reformat an enumerated value depending on whether I am "grading" or not, and I have a working solution, but I would like to know would be how to automatically switch between \theenumi
, \theenumii
, and \theenumiii
based on \@enumdepth
in the minimum working example that I have posted below:
\documentclass{article}
\usepackage{ifthen, amsmath, tikz, enumerate}
\newif\ifgrading
\gradingtrue
\newcommand*\circleAns[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=2pt,color=blue] (char) {#1};}}
\makeatletter
\newcommand{\itemAns}{
\ifgrading
\stepcounter{enum\romannumeral\@enumdepth}
\item[\circleAns{\textcolor{blue}{\theenumi)}}]
\else \item
\fi
}
\makeatother
\begin{document}
\begin{enumerate}[a)]
\item
\itemAns
\item
\end{enumerate}
\end{document}
I tried using \theenum\romannumeral\@enumdepth
instead of \theenumii
, similar to what I did with \stepcounter{enum\romannumeral\@enumdepth}
, which didn't work though I think I understand why. If anyone has any suggestions for how to implement this solution better and update based on the level, I am very open to suggestions.
--------------------------- EDIT
Using Donald Arseneau's solution as a basis, I've modified my implementation to also include the label automatically: \textcolor{ForestGreen}{\@nameuse{label\@enumctr}}
So the code
\begin{enumerate}[a)]
\item
\itemAns
\item
\end{enumerate}
\begin{enumerate}[a.]
\item
\item
\itemAns
\end{enumerate}
produces
So it has the functionality I need it to. If anyone knows a simple way of recentering the circled items, let me know but otherwise I'm very happy with the result!