1

The labels in itemize-like lists created with enumitem don't seem to obey \@listdepth. Consider the following. We define two types of lists

\documentclass{article}

\usepackage{enumitem}

\newlist{foolist}{itemize}{2}
\newlist{barlist}{itemize}{2}
\setlist[foolist,1]{label=\textbullet}
\setlist[foolist,2]{label=\textendash}
\setlist[barlist,1]{label=\textbullet}
\setlist[barlist,2]{label=\textendash}

With either type of list we should get a bullet when the list is not nested and a dash when it is. However, in practice, this only occurs if the parent list is the same kind as the nested one.

\begin{document}

\makeatletter
\begin{foolist}
  \item Foo \the\@listdepth
    \begin{foolist}
      \item Foo \the\@listdepth
    \end{foolist}
\end{foolist}

\begin{foolist}
  \item Foo \the\@listdepth
    \begin{barlist}
      \item Bar \the\@listdepth
    \end{barlist}
\end{foolist}
\makeatother

\end{document}

The code above produces

* Foo 1
  - Foo 2

* Foo 2
  * Bar 2

Even though \@listdepth in the last barlist is set two 2, the label is a bullet.

How can I make the labels to depend solely on the value of \@listdepth regardless of the kind of list?

1
  • 1
    The depth is defined in a new counter of every initialised environment with enitdp@<env-name> Sep 19, 2013 at 21:13

1 Answer 1

2

You could use \@listdepth as part of the label key:

enter image description here

\documentclass{article}

\usepackage{enumitem}% http://ctan.org/pkg/enumitem

\newlist{foolist}{itemize}{2}
\newlist{barlist}{itemize}{2}
\makeatletter
\setlist[foolist]{label={\ifnum\@listdepth=\@ne\textbullet\else\textendash\fi}}
\setlist[barlist]{label={\ifnum\@listdepth=\@ne\textbullet\else\textendash\fi}}
\makeatother
\begin{document}

\makeatletter
\begin{foolist}
  \item Foo \the\@listdepth
    \begin{foolist}
      \item Foo \the\@listdepth
    \end{foolist}
\end{foolist}

\begin{foolist}
  \item Foo \the\@listdepth
    \begin{barlist}
      \item Bar \the\@listdepth
    \end{barlist}
\end{foolist}
\makeatother

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .