5

I'm trying to typeset a numbered list in which I'm overriding the default enumerate behaviour using enumitem so that there's text in addition to a number. I'd like the text to be flush with the left margin, and I've found this solution to that particular problem.

However, My problem turns out to be more complicated. In addition, I sometimes need to override the regular overrided behaviour of my enumerate environments mid-list by including different text for some items mid-list. I'd like these items to still be flush with the left margin. For example:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{calc}
\usepackage{lipsum}


\begin{document}

\lipsum[1]

\subsection*{Using description}

\begin{description}
 \item[\bfseries Item 1:] Left margin: \the\leftmargin
 \item[\bfseries Much longer item 2:] Right margin: \the\rightmargin
 \item[\bfseries Item 3:] Listparindent: \the\listparindent
 \item[\bfseries Item 4:] Label width: \the\labelwidth
 \item[\bfseries Item 5:] Label sep: \the\labelsep
 \item[\bfseries Item 6:] Label indent: \the\labelindent
 \item[\bfseries Item 7:] Item indent: \the\itemindent
 %\item[\bfseries Much longer item 8:] \lipsum[2]
\end{description}

\subsection*{Using enumerate}

\begin{enumerate}[label={\bfseries Item \arabic*:},labelindent=0pt,labelwidth=\widthof{\ref{last-item}},itemindent=1em,leftmargin=!]%itemindent=-20pt, labelwidth=0pt]
 \item Left margin: \the\leftmargin
 \item[\bfseries Much longer item 2]: Right margin: \the\rightmargin
 \stepcounter{enumi}
 \item Listparindent: \the\listparindent
 \item Label width: \the\labelwidth
 \item Label sep: \the\labelsep
 \item Label indent: \the\labelindent
 \item Item indent: \the\itemindent \label{last-item}
 %\item \lipsum[2]
\end{enumerate}

\lipsum[3]


\end{document}

I've included a description environment for comparison: this is what I'd like my enumerate to look like.

output

So basically, I'm looking for a way to make enumerate behave like description in terms of horizontal spacing, but I don't want to just use description because the automated numbering of items is important. Any ideas?

6

Just use [leftmargin=*, align=left] as your enumerate parameters.

The output is identical but the values printed of the lengths are different because of the way the default description values are calculated. Using leftmargin=! will achieve the same value for the left indent, but a different value for the item indent.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}

\begin{document}


\subsection*{Using description}

\begin{description}[]
 \item[\bfseries Item 1:] Left margin: \the\leftmargin
 \item[\bfseries Much longer item 2:] Right margin: \the\rightmargin
 \item[\bfseries Item 3:] Listparindent: \the\listparindent
 \item[\bfseries Item 4:] Label width: \the\labelwidth
 \item[\bfseries Item 5:] Label sep: \the\labelsep
 \item[\bfseries Item 6:] Label indent: \the\labelindent
 \item[\bfseries Item 7:] Item indent: \the\itemindent
 %\item[\bfseries Much longer item 8:] \lipsum[2]
\end{description}

\subsection*{Using enumerate}

\begin{enumerate}[label={\bfseries Item \arabic*:},leftmargin=*,align=left]
 \item Left margin: \the\leftmargin
 \item[\bfseries Much longer item 2]: Right margin: \the\rightmargin
 \stepcounter{enumi}
 \item Listparindent: \the\listparindent
 \item Label width: \the\labelwidth
 \item Label sep: \the\labelsep
 \item Label indent: \the\labelindent
 \item Item indent: \the\itemindent \label{last-item}
\end{enumerate}

\end{document}

output of code

| improve this answer | |
  • Or wide=0pt, still simpler ;o) – Bernard Sep 12 '15 at 22:05
  • It looks like align=left is the only alignment parameter I need to set... feeling like I should have RTFM (I really did read it, but it's pretty overwhelming). Thanks! – rainbowgoblin Sep 13 '15 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.