[Tex/LaTex] How to change the number of enumerate items?

#enumeratenumbering

Ok, since this question seems to be pretty easy (well I still don't know the answer and didn't find something on this site), I'll try it without MWE: I'd like to know how to change the number of items in enumerate environments. Most appreciated would be solutions without additional packages or such…

\begin{enumerate}
  \item The fifth item
  \item The seventh item
\end{enumerate}

This should result in

5. The fifth item
7. The seventh item

and not in the normal items numbered 1 and 2. It probably has to do something with counters!?

Best Answer

  1. Set the enumi counter and do it through a command for easiness (for a more general answer, see below):

    \documentclass{article}
    
    \newcommand\setItemnumber[1]{\setcounter{enumi}{\numexpr#1-1\relax}}
    
    \begin{document}
    
    \begin{enumerate}
      \setItemnumber{5}
      \item The fifth item
      \setItemnumber{7}
      \item The seventh item
    \end{enumerate}
    
    \end{document}
    

    enter image description here

    Since the previous definition of the command uses enumi, the defined command \setItemnumber will only work for the first level for nested enumerates. Using the \@enumdepth counter (controlling the nesting depth for enumerated lists), the command can be improved so as to be used for every level in nested enumerations:

    \documentclass{article}
    
    \makeatletter
    \newcommand\setItemnumber[1]{\setcounter{enum\romannumeral\@enumdepth}{\numexpr#1-1\relax}}
    \makeatother
    
    \begin{document}
    
    \begin{enumerate}
      \setItemnumber{5}
      \item The fifth item
      \begin{enumerate}
        \setItemnumber{3}
        \item The third subitem
        \setItemnumber{9}
        \item The ninth subitem
      \end{enumerate}
      \setItemnumber{7}
      \item The seventh item
    \end{enumerate}
    
    \end{document}
    

    The result:

    enter image description here

  2. Use the optional argument for \item (but you loose in this way the possibility to do cross-references to those items):

    \documentclass{article}
    
    \begin{document}
    
    \begin{enumerate}
      \item[5.] The fifth item
      \item[7.] The seventh item
    \end{enumerate}
    
    \end{document}
    
Related Question