9

This is my current code. I've managed to get one next enumeration but I want a third nesting to replace me having to write 1.1.1, 1.1.2 etc.

 \begin{enumerate}
 \item Top Levek
   \begin{enumerate}
   \item Second Level
     \begin{enumerate}
     \item Third Level
     \end{enumerate}
   \end{enumerate}
 \end{enumerate}

This gives me

1 Top Level
1.1 Second Level
i Third Level

My desired output is

1 Top Level
1.1 Second Level
1.1.1 Third Level

How do I achieve this?

Also, how do I remove the indentation on the third level so it is inline with the second level?

  • 1
    Welcome to TeX.SX! Ehen you post a question it's better to give a complete minimal working example. This should be as small as possible to demonstrate your problem and compile. This both clarifies your question and makes it easier to help you! – Andrew Oct 29 '18 at 9:56
  • 1
    Welcome to TeX.SE. Please tell us if your document loads any packages that influence the appearance of numbers used in enumerations. For sure, the LaTeX default for second-level enumerated items is (a), (b), etc., not 1.1, 1.2, etc. Please also advise whether or not second-level enumerated items should be left-indented with respect to first-level enumerated items. – Mico Oct 29 '18 at 9:56
  • What should be inline with the second level? The label or the texts that follow the labels? – Bernard Oct 29 '18 at 10:16
  • @Bernard the answer given is what I was looking for. However, if you know how to get both the labels in line with each other and the text in line with each other also that'd be great. – Maria Robson Oct 29 '18 at 10:43
  • If you'd asked for this alignment of the labels in the OP then that's what I would have given... – Andrew Oct 29 '18 at 13:51
9

Is it this alignment you wish?

\documentclass{article}
\usepackage{enumitem}
\usepackage[showframe]{geometry}

\newlength{\labelwd}
\settowidth{\labelwd}{9.9.9}
\setlist[enumerate]{label*=.\arabic*, wide = 0.5em, labelwidth=\labelwd}
\setlist[enumerate, 1]{label=\arabic*}
\setlist[enumerate, 2,3]{labelindent=-\dimexpr\labelwd+\labelsep}

\begin{document}

 \begin{enumerate}[leftmargin=\dimexpr\labelwd+\labelsep + 0.5em,]
    \item Top Level. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.
    \begin{enumerate}
        \item Second Level. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.
        \begin{enumerate}%[labelindent = -\dimexpr1cm + \labelsep]
        \item Third Level. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.
        \end{enumerate}
   \end{enumerate}
\end{enumerate}

\end{document} 

enter image description here

|improve this answer|||||
8

You can use the enumitem package to produce:

enter image description here

Here's the code:

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate,1]{label=\arabic*}
\setlist[enumerate,2]{label=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\theenumii.\arabic*}
\begin{document}

\begin{enumerate}
 \item Top Levek
   \begin{enumerate}
   \item Second Level
     \begin{enumerate}
     \item Third Level
     \end{enumerate}
   \end{enumerate}
 \end{enumerate}

\end{document}

The important bits are the lines

\usepackage{enumitem}
\setlist[enumerate,1]{label=\arabic*}
\setlist[enumerate,2]{label=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\theenumii.\arabic*}

These specify what you want the labels to look like. I highly recommend reading the package manual if you need to tweak further. It's very to easy to read.

Edit TO get the indentation in the OP you can use:

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{
   leftmargin=0pt, labelindent*=0pt, labelwidth=0pt,align=left
}
\setlist[enumerate,1]{label=\arabic*}
\setlist[enumerate,2]{label=\theenumi.\arabic*}
\setlist[enumerate,3]{label=\theenumii.\arabic*}

\begin{document}

\begin{enumerate}
 \item Top Level
   \begin{enumerate}
   \item Second Level
     \begin{enumerate}
     \item Third Level
     \end{enumerate}
   \end{enumerate}
 \end{enumerate}

\end{document}

to give:

enter image description here

EDIT II As Mico says in the comments, for the required indentation it is easier to use \setlist[enumerate]{ wide=0pt }.

|improve this answer|||||
  • 2
    Why not use \setlist[enumerate]{label*=\arabic*.} instead? – leandriis Oct 29 '18 at 9:59
  • 2
    This solution doesn't address the OP's objective to "remove the indentation on the third level so it is inline with the second level". – Mico Oct 29 '18 at 10:10
  • @leandriis - The OP has stated that he/she does not want a period (aka "full stop") at the end of the numeric labels. – Mico Oct 29 '18 at 10:11
  • @leandriis Thanks for that. I did not know about label*! – Andrew Oct 29 '18 at 10:15
  • 1
    Simpler than leftmargin=0pt, labelindent*=0pt, labelwidth=0pt,align=left is wide=0pt. – Mico Oct 29 '18 at 10:18
0

If you don't want to use a new package, you can define new list environnement.

With my ugly solution, if you write nothing after an item and you open a new list just after, the numbers appears only one time, like show here:

enter image description here

LaTeX render this very well, but I do it without any care.

Here is the code:

\documentclass{article}

\newcounter{123num}
\newenvironment{123item}
  {\begin{list}{\textbf{\arabic{123num}}}
               {\usecounter{123num}
                \setlength{\leftmargin}{1.4em}
               }}
  {\end{list}}

\newcounter{sous123num}
\newenvironment{sous123item}
  {\begin{list}{\textbf{\arabic{123num}.\arabic{sous123num}}}
               {\usecounter{sous123num}
                \setlength{\labelwidth}{1.8em}
                \setlength{\leftmargin}{0.9em}
               }}
  {\end{list}}

\newcounter{soussous123num}
\newenvironment{ss123item}
  {\begin{list}{\textbf{\arabic{123num}.\arabic{sous123num}.\arabic{soussous123num}}}
               {\usecounter{soussous123num}
                \setlength{\labelwidth}{2.7em}
                \setlength{\leftmargin}{0.9em}
               }}
  {\end{list}}

\begin{document}

\begin{123item}
 \item Top Level
   \begin{sous123item}
   \item 
     \begin{ss123item}
     \item Third Level
     \end{ss123item}
   \item Second Level
   \end{sous123item}
 \end{123item}

\end{document}
|improve this answer|||||

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.