6

In my document, I need to temporarily modify the settings of enumerate environment, using the options offered by theenumitem package. Hence I use :

\setlist[enumerate,1]{align=right,leftmargin=0pt,labelsep=0pt,label=\llap{\bfseries{\arabic*.} \hskip 9pt}}
  \setlist[enumerate,2]{align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,label=\llap{\bfseries{\arabic{enumi}.\alph*.} \hskip 9pt}}
  \setlist[enumerate,3]{align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,label=\llap{\bfseries{\arabic{enumi}.\alph{enumii}.\roman*.} \hskip 9pt}

which does exactly what I want. However, how can I later restore the defaults settings, I cannot find the default values in the documentation ?

mvienney
  • 986

3 Answers3

8

You can restore the original settings by simply neutralizing the custom settings you introduced. So, to undo the three settings you made, you can add this:

\setlist[enumerate,1]{}%
\setlist[enumerate,2]{}%
\setlist[enumerate,3]{}%

to your code wherever you want the original enumerate. But, when the custom settings are needed again, you will have to re-issue your three custom settings and so on. You can make two shortcut commands, one for each settings group, to simplify the markup.

\documentclass{article}
\usepackage{enumitem}

\setlist[enumerate,1]{align=right,leftmargin=0pt,labelsep=0pt,label=\llap{\bfseries{\arabic*.} \hskip 9pt}}
\setlist[enumerate,2]{align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,label=\llap{\bfseries{\arabic{enumi}.\alph*.} \hskip 9pt}}
\setlist[enumerate,3]{align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,label=\llap{\bfseries{\arabic{enumi}.\alph{enumii}.\roman*.} \hskip 9pt}}

\begin{document}

Modified enumerate here ...
\begin{enumerate}
\item{First}
\begin{enumerate}
    \item{First-1}
    \item{First-2}
\end{enumerate}
\item{Second}
\end{enumerate}

\setlist[enumerate,1]{}%
\setlist[enumerate,2]{}%
\setlist[enumerate,3]{}%

Original enumerate here ...
\begin{enumerate}
\item{First}
\begin{enumerate}
    \item{First-1}
    \item{First-2}
\end{enumerate}
\item{Second}
\end{enumerate}

\end{document}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
4

I think it's great solution to have another list, rather than setting enumerate, as Aubrey says. Here I present you another one that is usually forgotten and comes in handy many times. (May be this is not the perfect occasion, but other times it is useful.)

\SetEnumitemKey{personalpreference1}
  {align=right,leftmargin=0pt,labelsep=0pt,
   label=\makebox[0pt][r]{\textbf{\arabic*.} \hspace{9pt}}}
\SetEnumitemKey{personalpreference2}
  {align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,
   label=\makebox[0pt][r]{\textbf{\arabic{enumi}.\alph*.} \hspace{9pt}}}
\SetEnumitemKey{personalpreference3}
  {align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,
   label=\makebox[0pt][r]{\textbf{\arabic{enumi}.\alph{enumii}.\roman*.} \hspace{9pt}}}

and then use \begin{enumerate}[personalpreference1], etc.

Here are two examples where I think it's useful.

\documentclass{scrartcl}
\usepackage{enumitem}

\SetEnumitemKey{ncases}
  {itemsep=0pt,align=left,leftmargin=\parindent,
   itemindent=!,label={\normalfont\textit{Case $\arabic*$}:}}
\newcommand*\makelabelcases[1]{\textit{Case $#1$}:}
\SetEnumitemKey{cases}
  {itemsep=0pt,align=left,leftmargin=\parindent,
   itemindent=!,before=\let\makelabel\makelabelcases}

\begin{document}

\begin{enumerate}[ncases]
 \item First item.
 \item Second item.
 \item Third item.
\end{enumerate}
\begin{description}[cases]
 \item[n = 0] Whatever.
 \item[n \neq 0] Whatever.
\end{description}

\end{document}

enter image description here

I think \SetEnumitemKey is often forgotten and sometimes it's more appropiate than \newlist + \setlist.

Manuel
  • 27,118
3

You should provide a MWE so your helpers can easily check their responses. However you will be best creating a new list type, and use this when you want it, leaving the originals untouched. Something like:

\newlist{ownlist}{enumerate}{3}
\setlist[ownlist,1]{align=right,leftmargin=0pt,labelsep=0pt,label=\llap{\bfseries{\arabic*.} \hskip 9pt}}
  \setlist[ownlist,2]{align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,label=\llap{\bfseries{\arabic{enumi}.\alph*.} \hskip 9pt}}
  \setlist[ownlist,3]{align=right,leftmargin=0pt,labelsep=0pt, labelwidth=!,label=\llap{\bfseries{\arabic{enumi}.\alph{enumii}.\roman*.} \hskip 9pt}

Then use as

\begin{ownlist}
\item First level. etc Reference to item \ref{itm:gthirdlvlb}
...
\end{ownlist}