I would like to have my lists to have no indent for the top level, i.e. having the same left margin as the surrounding paragraph, with just enough space for the widest label to fit:
Paragraph text
1. Item
2. Item
3. Item
...
10. Item
Paragraph text
I already do something similar for itemize
and description
, using the enumitem
package:
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*}
\setlist[description]{leftmargin=*}
But apparently enumerate
has some issues determining the width of its labels. It starts with a shaky assumption, which pushes small labels too far to the right, and extends beyond the left margin if the enumeration gets big enough (I know the 10000 value is ridiculous, it's just to make my point obvious):
\documentclass[twocolumn]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\newcommand{\justsometext}{Just enough text to make the line break so we get to see a second line.}
\begin{document}
\justsometext
\begin{enumerate}
\item \justsometext
\begin{enumerate}
\item Nested. \justsometext
\end{enumerate}
\item \justsometext
\addtocounter{enumi}{9997}
\item \justsometext
\end{enumerate}
\justsometext
\end{document}
The enumitem
package gives me half of a way around it, but it requires me to state the widest label
\usepackage{enumitem}
\setlist[enumerate]{leftmargin=*}
% ...
\begin{enumerate}[widest=10000]
% ...
However, isn't there some way to make enumerate
detect the width of its widest label automatically, instead of having to set it for each individual list? I feel like there must be some way, I just couldn't figure out how from the enumitem
doc...
(I tried the paralist
package with option alwaysadjust
, as well as compactenum
from the same package; both are worse than what I got from enumitem
: assuming some label width first - pushing the "1." and "2." from the left margin - then ruining the alignment completely when the 10000 label pushes its item to the right...)
\setlist[enumerate]{leftmargin=*,widest=0}
, and overriding thewidest
setting for all lists with >9 elements...