2

This is a follow up from a previous query.

Code:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{diagbox}
\usepackage[margin=1in]{geometry}

\begin{document} \begin{enumerate}[itemindent = {\widthof{\arabic.} + \labelsep}, leftmargin =] \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \addtocounter{enumi}{9} \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \end{enumerate} \end{document}

I would like to align the numbers by the most significant digit instead of the least significant digit (which is pretty common). However, it seems that the numbers are aligned by the least significant digit as shown below (and I’m getting an error; I’m using TeXpad):

enter image description here

How to align the numbers by the most significant digit as well as the multi-line content starting from the second line? The first one did well, but the second enumeration does not do as desired.

Addendum: Problem solved by Bernard. Now here is a case:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{diagbox}
\usepackage[margin=1in]{geometry}

\begin{document} \begin{enumerate}[wide = 0pt] \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \addtocounter{enumi}{9} \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \item \begin{enumerate}[wide = 0pt] \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would \end{enumerate} \end{enumerate} \end{document}

Output:

enter image description here

Here, the nested enumerators aren’t aligned. Just wondering if there is a way to align the enumerators while aligning the “overflowing” lines at the most significant digit of the outer enumerator.

Superman
  • 1,615

1 Answers1

3

If I've well understood what you want, the option [wide=0pt] should do it: in this case, the labels are left-aligned. In case of nested enumerate, we need some more parameters:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{diagbox}
\usepackage{calc} 
\usepackage[margin=1in, showframe]{geometry}

\begin{document}

\begin{enumerate}[wide =0pt]%
    \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would \addtocounter{enumi}{9}
    \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would
    \item 
\begin{enumerate}[wide=1.8em, leftmargin=1.8em, before=\hspace*{-1.8em}\vspace*{-\baselineskip-2\topsep}]
    \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
    \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
\end{enumerate}
\end{enumerate}

\end{document}

enter image description here

To have all second lines of items aligned at the text left margin, remove the leftmargin=1.8em in the options of the second level enumerate, like this:

\begin{enumerate}[wide =0pt]%
    \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would \addtocounter{enumi}{9}
    \item Ppppp pppp ppppppp ppp pppp ppppp pppp pppp ppppp ppppp pppp ppp ppp ppp ppp but rather I would
    \item 
\begin{enumerate}[wide=1.8em, leftmargin=1.8em, before=\hspace*{-1.8em}\vspace*{-\baselineskip-2\topsep}]
    \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
    \item Ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp but rather I would
\end{enumerate}
\end{enumerate}

enter image description here

Bernard
  • 271,350
  • This would work if there are nested enumerations. If I try to make a nested enumeration right away without adding in the outer enumeration, the nested enumerators won’t line up. I will accept this answer for the case shown in my query. – Superman Jan 03 '21 at 00:40
  • Could you post a small code illustrating your problem? – Bernard Jan 03 '21 at 00:41
  • Posted in the main question. – Superman Jan 03 '21 at 00:47
  • It's trickier, and it's getting late here. I'll look at that tomorrow, but the general idea would be to nest the second level enumerate in an adjustwidth environment from the changepage package, that allows for local modifications of the text horizontal margins. – Bernard Jan 03 '21 at 01:01
  • No worries. No Rush. – Superman Jan 03 '21 at 01:32
  • 1
    @Superman: I've finally found a solution for nested enumerates using only the tools of enumitem. – Bernard Jan 03 '21 at 13:24
  • Hi Bernard, just saw this. Can you post a solution such that for 12(a) and 12(b), the second line lines up with the 1 instead of the nested enumerator? Please write another solution instead of overwriting that. – Superman Jan 03 '21 at 17:00
  • To make it clear, the second lines of the second level items should align with the text left margin? – Bernard Jan 03 '21 at 17:12
  • Hi Bernard, yes. Not sure if it’s standard to do so, because if my equations are long, they would be longer than the length of the second level item such that it would be at the text left margin. – Superman Jan 03 '21 at 17:29
  • I think it's not readable as r=the initial version I posted, but it's easy to do. I'll post it within seconds. – Bernard Jan 03 '21 at 17:35
  • Thank you for your help! Here, is 1.8em the standard spacing between the outer and inner enumerators? – Superman Jan 03 '21 at 18:44
  • No, I just set a length that looked pleasant to my eyes. You may adjust it to your needs and/or taste. It just had to be a bit more than the width of a two-digit number. – Bernard Jan 03 '21 at 18:47
  • Oh ok, not sure if the enumitem manual says it, but if it mentions the default value of the spacing (which it should), then it would be nice. – Superman Jan 03 '21 at 18:48