2

I'm working on a text that has a long list of numbered items (some with sub-numbers). Under normal circumstances, there wouldn't be an issue, but someone (not me) wanted to have cross-references to another set of numbered items. If the items in "my" list are capital letters and the items in the other list are lower-case letters, the top level of the list looks like this:

A (a). B (b). C (f). D (h and u). E (z).

There is no double-labeling of the sub-item lists.

Is there a way to add an (optional) argument to \enumerate that will add a number I give it in parentheses AND eliminate the parenthetical argument if I don't give it that argument? Something like this:


\item First item

\item {32} Second item
\begin{enumerate}
\item Sub-item one
\item Sub-item two
\item Sub-item three
\end{enumerate}

\item {4 and 68} Third item

\item Fourth item
\end{enumerate}

That would, in principle, produce:

  1. First item

2 (32). Second item

a) Sub-item one

b) Sub-item two

c) Sub-item three

3 (4 and 68). Third item

  1. Fourth item

(Note the location of the full stop after each label and the parentheses in the second-level list.)

2
  • I don't understand your question fully. Are the bracketed numbers references to some other examples? In that case it won't be advisable to add the numbers manually. One can automate it. When you write "2 (32).", does that mean "this is example number 2 with sub-example number 32" or "this is example number 2, c.f. example/sub-example number 32"?
    – Niranjan
    Jun 20 at 5:25
  • Adding the number in brackets is required since there's no real rhyme or reason to their order. Jun 21 at 0:54

1 Answer 1

5

It's difficult to do it really generally with \item.

\documentclass{article}
\usepackage{enumitem}

\newlist{bienumerate}{enumerate}{1}
\setlist[bienumerate]{%
  label=\arabic*\additionallabel.,
  wide,
}
\NewDocumentCommand{\additionallabel}{}{}
\NewDocumentCommand{\biitem}{o}{%
  \IfNoValueTF{#1}{%
    \renewcommand{\additionallabel}{}%
  }{%
    \renewcommand{\additionallabel}{ (#1)}%
  }%
  \item
}

\begin{document}

\begin{bienumerate}
\biitem First item
\biitem[32] Second item
\biitem[4 and 68] Third item
\biitem Fourth item
\end{bienumerate}

\begin{bienumerate}[label=\Alph*\additionallabel.]
\biitem First item
\biitem[32] Second item
\biitem[4 and 68] Third item
\biitem Fourth item
\end{bienumerate}

\end{document}

enter image description here

3
  • This is brilliant. I have two questions regarding the solution: First, what is the name of the new counter? I have to periodically (often) stop and then continue the list from the last stopping point, and using setcounter{enumi}{number} doesn't seem to work. Secondly (and only because I haven't tried it yet - too excited!), I assume that "regular" enumerate second-tier lists work as usual? Jun 21 at 0:56
  • Putting the alphabetical list as a secondary (indented) list inside the first original list does not seem to work. Jun 21 at 3:16
  • 1
    @KarlWolfschtagg You want to use enumerate for the nested list: you said that the nested lists don't need the double numbering. For the other problem, look for resume in the documentation of enumitem.
    – egreg
    Jun 21 at 7:17

You must log in to answer this question.

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