17

How can I skip every even item in the enumerate environment without having to continually type \setcounter{enumi}{5}? I am still learning to program macros, so I spologize if this is a ridiculously easy question.

Just to be clear, I would like something like

1. *Something.* 3. *Somthing else.* 5. *A third something.* ...As opposed to

1. Something. 2. A second something. 3. A tertiary Something.

Masroor
  • 17,842
Qu0rk
  • 507

2 Answers2

17

This is for first level enumerations; other levels can be added in a similar way.

\documentclass{article}
\usepackage{enumitem}

\newlist{oddenumerate}{enumerate}{1}
\setlist[oddenumerate]{start=0,label=\theoddenumeratei.}
\makeatletter
\renewcommand\theoddenumeratei{\@arabic{\numexpr2*\value{oddenumeratei}+1}}
\makeatother

\begin{document}
\begin{oddenumerate}
    \item one
    \item two\label{two}
    \item three
\end{oddenumerate}

Here's a ref: \ref{two}
\end{document}

enter image description here

egreg
  • 1,121,712
5

The following example defines macros \arabicodd and \arabiceven that works similar to \arabic, but using odd and even numbers respectively.

As in the other answers of cmhughes and egreg, the list is made via package enumitem.

References work in the same way as for the "normal" enumerate environment, especially, the dot is not included in the reference. The appearance of the label and reference can easily be configured options label and/or ref. The counters macros \arabicodd and \arabiceven can be used as \arabic there, because they are registered using \AddEnumerateCounter.

\documentclass{article}

\usepackage{enumitem}

\makeatletter
\newcommand*{\arabicodd}[1]{%
  \expandafter\@arabicodd\csname c@#1\endcsname
}
\newcommand*{\arabiceven}[1]{%
  \expandafter\@arabiceven\csname c@#1\endcsname
}
\newcommand*{\@arabicodd}[1]{%
  \@arabic{\numexpr(#1)*2-1\relax}%
}
\newcommand*{\@arabiceven}[1]{%
  \@arabic{\numexpr(#1)*2\relax}%
}

\AddEnumerateCounter\arabicodd\@arabicodd{0}
\AddEnumerateCounter\arabiceven\@arabiceven{0}
\makeatother

\begin{document}
  \begin{enumerate}
      \item one
      \item\label{normal:two}two
      \item three
  \end{enumerate}
  Middle label of normal numbered list: \ref{normal:two}.

  \begin{enumerate}[label=\arabicodd*.,ref=\arabicodd*]
      \item one
      \item\label{odd:two}two
      \item three
  \end{enumerate}
  Middle label of odd-numbered list: \ref{odd:two}.

  \begin{enumerate}[label=\arabiceven*.,ref=\arabiceven*]
      \item one
      \item\label{even:two}two
      \item three
  \end{enumerate}
  Middle label of even-numbered list: \ref{even:two}.
\end{document}

Result

Heiko Oberdiek
  • 271,626
  • This is a really useful answer- while I wish I could mark both as the answer, the above answer gives finer control with fewer lines of code. Thanks again! – Qu0rk Jun 12 '14 at 00:56