12

Is there an easy way to combine two items in an enumerated list? For example:

1.   First bullet
2-3. Second bullet
4.   Third bullet

My current plan involves screwing with \labelenumi and then manually incrementing \enumi, but that seems ugly

3
  • Don't know if it's true, but if you are in a situation in which you don't decide the numbers, or at least they're fixed and will never change (for example typing up answers to a problem set), then I would suggest that you do a custom label for every item (using enumitem perhaps), since that way you can see which number you're on in the code. Also, if you decide to split #2 and #3 up later on, it won't mess up the subsequent numbering. Dec 1, 2011 at 4:29
  • @JohnJamesSmith That's exactly the situation; I'm answering two parts of a homework problem (a and b) at once. I normally just use comments above each \item to track the number, but enumitem looks interesting Dec 1, 2011 at 4:34
  • Haha, just checked. You can forget enumitem. See my answer. Dec 1, 2011 at 4:41

2 Answers 2

16

Here's a more automated solution that saves you the trouble of numbering by hand. The basic idea is to define a new kind of \item called \combine which combines n items into one, where n can be specified as an optional argument (default 2).

In order to deal with enumerations with different label formats (alpha, roman etc.) I've also added a command to set the label format for the combined labels. This can be done before any particular list, or once in the document if all the lists will require combined elements will be of the same sort.

One caveat: don't try to use \label with the combined items.

\documentclass{article}
\usepackage{calc}
\makeatletter
\newcounter{tmp@cnt}
\newcommand*\@labelpunc{.}
% command to combine items: optional argument to specify the number to be combined
% \combine[<num>]<item>
%
\newcommand*\combine[1][2]{%
    \refstepcounter{enumi}
    \setcounter{tmp@cnt}{\value{enumi}}
    \addtocounter{enumi}{#1-1}
    \item[\thetmp@cnt--\theenumi\@labelpunc]}
% command to set the label format and punctuation
% \labeltype[<punc>]{<format>} where default punctuation is none; <format> is 
% \alph \Alph \roman \Roman etc.  Not needed for default enumerations
%
\newcommand*\labeltype[2][]{\gdef\@labelpunc{#1}\renewcommand\thetmp@cnt{#2{tmp@cnt}}}
\makeatother
\usepackage{enumitem} % for demonstration purposes (not required for the above commands)
\begin{document}
\begin{enumerate}
\item An item
\item Another item
\combine Two items combined
\item Another one
\combine[4]Four items combined
\end{enumerate}

\labeltype{\Roman}
\begin{enumerate}[label=\Roman*]
\item An item
\combine Two items combined
\item The last item
\end{enumerate}
\end{document}

output of code

9

Since you've indicated in the comments that the numbers-content mapping is fixed, I would use custom labels for every item. The purpose of using in enumerate environment is 1) to get the formatting of a list and 2) to make LaTeX keep track of the numbering for you so you don't have to. But here you want the numbers in your code so you can see what's what. I don't know if this is considered good style, but it's what I would do:

\begin{enumerate}
    \item[1] Let $p$ be a number. What if it doesn't want to be a number? Then \dots
    \item[2--3] I'm going to tackle two things at once here, that's how amazing I am
    \item[4] Assume not. Then the question writer has erred. Impossible!
\end{enumerate}

This has an additional benefit: If you change your mind later and want to split up items 2 and 3, then you won't have to bother with any extra enumi business or anything; just split the item.

You must log in to answer this question.

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