About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Latest news 2019-12-05: new blog post "RSS Feeds and Other Notifications."

Exercise 20: Extending the Maximum enumerate Depth (Solution)

This is a solution to Exercise 20.
\documentclass[numbers=endperiod]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

% Extended enumerate:

\newcounter{enumv}[enumiv]
\newcounter{enumvi}[enumv]
\newcommand*{\labelenumv}{\theenumv.}
\newcommand*{\labelenumvi}{\theenumvi.}

% Make the left margins a bit bigger for levels 5 and 6
\setlength{\leftmarginv}{15pt}
\setlength{\leftmarginvi}{15pt}

\makeatletter

\renewcommand*{\p@enumi}{}
\renewcommand*{\p@enumii}{}
\renewcommand*{\p@enumiii}{}
\renewcommand*{\p@enumiv}{}
\renewcommand*{\p@enumv}{}
\renewcommand*{\p@enumvi}{}

\renewcommand*{\enumerate}{%
\ifnum \@enumdepth > 5\relax
  \@toodeep
 \else
  \advance\@enumdepth\@ne
  \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
  \expandafter\list\csname label\@enumctr\endcsname{%
     \usecounter\@enumctr
     \def\makelabel##1{\hss\llap{##1}}%
   }%
\fi
}

\makeatother

% Modify item label formats
\renewcommand*{\labelenumi}{\theenumi.}
\renewcommand*{\labelenumii}{\theenumii.}
\renewcommand*{\labelenumiii}{\theenumiii.}
\renewcommand*{\labelenumiv}{\theenumiv.}

% Modify the way the item counters are displayed:

\renewcommand*{\theenumi}{\thesection.\arabic{enumi}}
\renewcommand*{\theenumii}{\theenumi.\arabic{enumii}}%
\renewcommand*{\theenumiii}{\theenumii.\arabic{enumiii}}%
\renewcommand*{\theenumiv}{\theenumiii.\arabic{enumiv}}%

% And for the new extended counters:
\renewcommand*{\theenumv}{\theenumiv.\arabic{enumv}}%
\renewcommand*{\theenumvi}{\theenumv.\arabic{enumvi}}%


\begin{document}
\section{Information About Us}

\begin{enumerate}
 \item This website is run by the Secret Lab of Experimental Stuff
  (``We'', ``Our''). We operate from the University of Somewhere.
\end{enumerate}

\section{Our Products}

\begin{enumerate}
 \item All Products shown on our site are subject to availability.

 \item You may only purchase our products if you are at least 18
  years old.
\end{enumerate}

\section{Refunds}

\begin{enumerate}
 \item You are entitled to a refund unless:
 \begin{enumerate}
   \item you have eaten the mind-controlling cookies;
   \item you have thrown the exploding chocolates;
   \item you have used the ray gun as:
   \begin{enumerate}
     \item a table chock;
     \item a weapon unless:
     \begin{enumerate}
       \item
         \label{permit}you have a ray gun permit;
       \item you are an extraterrestrial and:
       \begin{enumerate}
         \item are not a resident of the planet Earth;
         \item have a licence under Galactic Treaty 1024, unless:
         \begin{enumerate}
          \item you come under Article~24, or
          \item you live on Saturn.
         \end{enumerate}
       \end{enumerate}
     \end{enumerate}
   \end{enumerate}
 \end{enumerate}
\end{enumerate}

Cross-reference item~\ref{permit}.

\end{document}

Download enumextend.tex or enumextend.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs