I have the need for a custom list environment at the outermost level, defined as follows:
\newboolean{odd}
\setboolean{odd}{true}
\usepackage{environ}
\newcounter{exnum}[section]% Exercise counter (within section)
\NewEnviron{solution}{% Solution
\stepcounter{exnum}%
\ifthenelse{\isodd{\theexnum}}% Condition on oddness
{\item \BODY}% Print odd answer
{\ifthenelse{\boolean{odd}}{}{\item \BODY}}% Print odd
}
\newenvironment{outerlist}%
{\begin{list}%
{{\bfseries\arabic{exnum}.}}{}}%
{\end{list}}%
The point of all of this is to be able to set the odd
boolean and change whether all items, or just the odd-numbered items, are output.
This all works fine, except that this list environment, outerlist
, does not increment the enumeration level. As a result, inner enumerations start at level 1. This is not consistent with the visual appearance (outerlist
obviously looks like an outer enumeration in the output), and is confusing to the maintainer (I confused myself a couple of times 🙂
Can I tell LaTeX to start with enumeration level 2? Or is there a better way to write the above so as to get the behavior I want?
Edit: Per request, here is an MWE:
\documentclass{article}
\usepackage{environ}
\newcounter{itemnum}
\NewEnviron{outeritem}{% Solution
\stepcounter{itemnum}%
{\item \BODY}%
}
\newenvironment{outerlist}%
{\begin{list}%
{{\bfseries\arabic{itemnum}.}}{}}%
{\end{list}}%
\renewcommand{\labelenumi}{{\bfseries(\alph{enumi})}}
\renewcommand{\labelenumii}{{\bfseries(\roman{enumii})}}
\begin{document}
\begin{outerlist}
\begin{outeritem}
This level is numbered with arabic numerals, but is not really an enumerate list.
\end{outeritem}
\begin{outeritem}
This is outer list item 2.
\begin{enumerate}
\item This looks visually to be at level 2, but LaTeX thinks of it as a level 1 enum,
and it is governed by $\backslash$labelenumi. I would like it to be governed by
$\backslash$labelenumii, so that the TeX file can use level 2 definitions for
this list level format.
\end{enumerate}
\end{outeritem}
\end{outerlist}
\end{document}
Best Answer
It is possible to adjust the list depth/level. Let's see what
enumerate
does (taken fromlatex.ltx
):Within the definition
\advance\@enumdepth\@ne
increases the depth/level of the enumeration. We could defineand use it where needed:
Since I don't know the full extent of usage for
enumerate
inside your lists, you may have to consider demoting the level at the end ofouteritem
. For example, the following may be sufficient: