# Horizontal alignment issues with enumerate/description and sub-levels

I am struggling to obtain a proper horizontal alignment with either enumerate or description.

I have simple bold arabic numbers followed by a dot as labels. These are references to exercises, and so they can jump from 1. to 14. to 57. for example, hence a need for easy customization. The labels cannot go over the margin (I have tried the wide option for this) and cannot be indented. I would prefer the item text not to be indented (starting from the second line) to save space, but I can accept that it be indented such that it is aligned with the first line of text.

Then, some exercises have questions a., b., etc. which require an enumerate environment. The a. label will be on the first line, right beside the 1. for example, and the b. will be on another line (obviously). The main issue I wasn't able to solve from the answers I found here is: I want the a., b., ... labels to be aligned horizontally, along with their item text.

Finally, I would prefer not to write a lot of code in the preamble, as the file is meant to be reused easily by people with limited knowledge of LaTeX. My main concern is to get things right though, so if a custom environment is required, then so be it.

Here is the current state of my code:

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1in, includefoot,showframe]{geometry}

\usepackage{enumitem}
\newcommand\setItemNumber[1]{\setcounter{enumi}{\numexpr#1-1\relax}}

\begin{document}
\begin{enumerate}[label={\textbf{\arabic*.}},wide,leftmargin=*,labelindent=0pt]
\setItemNumber{19}
\item bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\setItemNumber{23}
\item \begin{enumerate}[label=\textbf{\alph*.}]
\item First question
\item Second question
\end{enumerate}
\end{enumerate}
\end{document}


EDIT Trying to obtain the same results with description, I had this kind of code:

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1in, includefoot,showframe]{geometry}

\usepackage{enumitem}

\begin{document}
\begin{description}
\item[2.] bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\item[56.] \begin{enumerate}[label=\textbf{\alph*.}]
\item bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\item bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\end{enumerate}
\end{description}
\end{document}


• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Sep 3, 2019 at 16:03

You didn't explain the description problem, but here is a solution for the enumerate problems, if I've well understood: for the 1st level enumerate, the solution is simplywide=0pt, a little more complex for the 2nd level.

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1in, includefoot,showframe]{geometry}

\usepackage[shortlabels]{enumitem}
\newcommand\setItemNumber[1]{\setcounter{enumi}{\numexpr#1-1\relax}}
\setlist[enumerate, 1]{1., font=\bfseries, wide=0pt}
\setlist[enumerate, 2]{a., font=\bfseries, wide=2em, leftmargin=2em, topsep=0pt, before=\leavevmode\vspace*{-\glueexpr\baselineskip+\parskip}}

\begin{document}
\begin{enumerate}[start=19]
\item bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\setItemNumber{23}
\item \begin{enumerate}
\item First question
\item Second question. bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\end{enumerate}
\item All mimsy were the borogoves,
And the mome raths outgrabe.
\end{enumerate}

\end{document}


• This seems to be it! Could you explain briefly what your second \setlist does, the before in particular and why 2em for wideand leftmargin? Sep 3, 2019 at 21:00
• Regarding description, it was an alternate way to get the desired result. I think in its purpose it may be better suited to my use, but it has the same problems and no wide option. If you can think of an elegant solution using description, I'm all ears though. Sep 3, 2019 at 21:10
• That was determined by trial and errors, so that the spacing between the 1st level number a the 2nd level list looked sensible. The value of wide and leftmargin had to be equal to get the second line vertically aligned with the (alphabetic) label. As to before, \leavevmode is a trick to have the sublist start on the next line exactly at the list left margin and the negative \vspace* lifts it up to the desired level. I hope I'm clear? Sep 3, 2019 at 21:12
• For the description environment, it's not very clear how you would use it. Could post an example of a case using description ? (possibly in a new question) Sep 3, 2019 at 21:15
• Very clear, but doesn't this value correspond to a list parameter that can be accessed with something like labelindent so that the exact value is used? Sep 3, 2019 at 21:42

The simplest solution uses only enumitem. This package is very efficient and there is no need to add anything :

To have the same space between the end of the labels and the beginning of the text, just delete the "align" or replace it with align=right. But whatever happens, you have to decide which side to align.

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{calc}

\newcommand{\setItemNumber}[1]{\setcounter{enumi}{\numexpr#1-1}}
\setlist[enumerate, 1]{label=\arabic*.,font=\bfseries,widest=50,leftmargin=\labelwidth+\labelsep,align=left}
\setlist[enumerate, 2]{label=\alph*., font=\bfseries, leftmargin=*, topsep=0pt}

\begin{document}
\lipsum[1-2][1-4]
\begin{enumerate}
\item \lipsum[1-2][1-4]
\setItemNumber{19}
\item \lipsum[1-2][1-4]
%\setcounter{enumi}{19}
\setItemNumber{23}
\item \begin{enumerate}
\item \lipsum[1-2][1-4]
\item \lipsum[1-2][1-4]
\end{enumerate}
\item \lipsum[1-2][1-4]
\end{enumerate}
\end{document}


Adding the widest=99 option fixes the horizontal alignment:

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1in, includefoot,showframe]{geometry}

\usepackage{enumitem}
\newcommand\setItemNumber[1]{\setcounter{enumi}{\numexpr#1-1\relax}}

\begin{document}
\begin{enumerate}[label={\textbf{\arabic*.}},wide,widest=99,leftmargin=*,labelindent=0pt]
\setItemNumber{19}
\item bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
\setItemNumber{23}
\item \begin{enumerate}[label=\textbf{\alph*.}]
\item First question
\item Second question
\end{enumerate}
\end{enumerate}
\end{document}

• The problem with widest=99` is that labels with only one digit now have has much indentation as those with two digits. Sep 3, 2019 at 18:30