TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there was a command to find what at what depth of the enum counter (i.e. enumi, enumii, etc.) a command was at compile time. I'm attempting to create a \question command. What I have so far:

\newcommand{\question}[2][\value{enumi}+1]{\setcounter{enumi}{#1-1} \item \textbf{#2}}

Which works great for the first level (Note: requires the calc package). What I'm looking for is a command (or series of commands) to replace the \value{enumi}+1 with whatever the current depth is so that something like:


would produce output like:

1. Whatever
10. Blah
   (b). Stuff
share|improve this question

migrated from stackoverflow.com Sep 5 '11 at 19:06

This question came from our site for professional and enthusiast programmers.

up vote 5 down vote accepted

You need to know the depth of the current enumerate to modify the appropriate counter; \@enumdepth holds the current enumeration nesting depth:


}{#1-1} \item \textbf{#2}}

           \question[6]{Other stuff}


enter image description here

share|improve this answer
You beat me to it. Two notes: 1) You don't need \the after \romannumeral as it automatically looks for a number; 2) I'd include the enum\romannumeral\@enumdepth in the default for the optional argument as well as in the command body. – Joseph Wright Sep 5 '11 at 19:19
@Joseph: ah, yes. Done! Thank you. – Gonzalo Medina Sep 5 '11 at 19:25
Thanks, I wasn't able to find anything on \@enumdepth when I was searching (although I can now obviously find plenty). – Drayton Munster Sep 5 '11 at 20:02
You can find the definition \newcount\@enumdepth \@enumdepth = 0 in the LaTeX kernel. Run texdoc source2e in a terminal, and search for \@enumdepth. – Gonzalo Medina Sep 5 '11 at 21:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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