Text FormattingLong enumerated List with custom Alignment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
audreyk
Posts: 23
Joined: Fri Nov 14, 2008 5:57 am

Long enumerated List with custom Alignment

Post by audreyk »

I want to create an automatic, left-aligned, numbered list that exceeds nine items, something like this:

1. xx
2. xx
3. xx
4. xx
5. xx
6. xx
7. xx
8. xx
9. xx
10. xx
11. xx
12. xx

BUT, here's the catch ... I want the text that follows each item (single & double-digits) to have the same alignment.

How do I accomplish this?

Any suggestions would be very welcomed.

Thanks,
audreyk

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

alainremillard
Posts: 45
Joined: Fri Mar 16, 2012 8:22 pm

Long enumerated List with custom Alignment

Post by alainremillard »

audreyk wrote:I want to create an automatic, left-aligned, numbered list that exceeds 9 items, something like this:

1. xx
2. xx
3. xx
4. xx
5. xx
6. xx
7. xx
8. xx
9. xx
10. xx
11. xx
12. xx
audreyk
Have a look at the enumitem package. It allows you to personnalise your numbered list. Here is an example of what you are looking for

Code: Select all

\documentclass{article}

\usepackage{enumitem}

\begin{document}

\begin{enumerate}[label=\arabic*.,align=left]
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
	\item 22
\end{enumerate}


\end{document}
Have a nice day
Alain Rémillard
audreyk
Posts: 23
Joined: Fri Nov 14, 2008 5:57 am

Re: Long enumerated List with custom Alignment

Post by audreyk »

Thanks, it worked!
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Long enumerated List with custom Alignment

Post by svend_tveskaeg »

If you want the text in every line, except the first in each \item, to extend into the left margin, you can do the following:

Code: Select all

\documentclass{article}

\newcounter{myenumi}
\renewcommand{\themyenumi}{(\roman{myenumi})}
\newenvironment{myenumerate}{%
% stuff for beginning of environment goes here
\setlength{\parindent}{0pt}% don't indent paragraphs
\setcounter{myenumi}{0}% restart numbering
\bigskip% skip a line
\renewcommand{\item}{% new definition of item
\par% start a new line
\refstepcounter{myenumi}% advance counter
\makebox[2.5em][l]{\themyenumi}% print counter to width of 3em, aligned to left
}% end of definition of item
}{% at end of environment
\par% start new paragraph
\bigskip% skip a line
\noindent% don't indent new paragraph
\ignorespacesafterend% ignore spaces after environment
}

\begin{document}

Here is some regular text, and I'm going to go on a bit just to see where it wraps and all that.
\begin{myenumerate}
\item Here is the first item which goes on a bit so we can see how it wraps, and it still needs to be longer.
\item Here is another item.
\item Here is yet another item.
\item And this item is going to be much much longer so we can see another example of one that wraps.
\end{myenumerate}
Here is some more regular text, and let's go on a bit here too, just in case it's important how that looks too.

\end{document}
I cannot remember when or where I got the code or from whom I got it but it is not my own suggestion.
Last edited by svend_tveskaeg on Fri Feb 01, 2013 2:32 am, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
audreyk
Posts: 23
Joined: Fri Nov 14, 2008 5:57 am

Long enumerated List with custom Alignment

Post by audreyk »

I like the flush left alignment of the list numbers and text (the fix works like a charm), but now I want to decrease the horizontal spacing slightly between the numbers and the start of the text after each item number. Can you show me how to do this?

Code: Select all

\documentclass{article}
\usepackage{enumitem}

\begin{document}

This is the start of a paragraph. This is the start of a paragraph. This is the start of a paragraph. This is the start of a paragraph.

\begin{enumerate}[label=\arabic*., align=left]
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\item This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines. This line wraps into two lines.
\end{enumerate}

This is the start of a paragraph. This is the start of a paragraph. This is the start of a paragraph. This is the start of a paragraph.

\end{document}
Thanks again!
Last edited by localghost on Thu Jan 31, 2013 11:38 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Long enumerated List with custom Alignment

Post by cgnieder »

You need to play a bit with the different widths and seps that are mentioned in the enumitem documentation. Something along these lines:

Code: Select all

\documentclass{article}
\usepackage{enumitem}

% the following two commands are just for laziness and
% keeping the example short:
\newcommand*\longitem{%
 \item This line wraps into two lines. This line wraps into two lines.
   This line wraps into two lines. This line wraps into two lines. This
   line wraps into two lines.
}
\newcommand*\twelveitems{%
  \longitem\longitem\longitem\longitem\longitem\longitem
  \longitem\longitem\longitem\longitem\longitem\longitem
}

\begin{document}

This is the start of a paragraph. This is the start of a paragraph. This is the
start of a paragraph. This is the start of a paragraph.

\begin{enumerate}[
  label       = \arabic*. ,
  align       = left ,
  leftmargin  = 1.75em ,% = labelwidth + labelsep + labelindent
  labelwidth  = 1.5em ,
  labelindent = 0em ,
  labelsep    = .25em]
 \twelveitems
\end{enumerate}

This is the start of a paragraph. This is the start of a paragraph. This is the
start of a paragraph. This is the start of a paragraph.

\end{document}
Maybe it is also better to define a custom list for this:

Code: Select all

\documentclass{article}
\usepackage{enumitem}

\newlist{myenumerate}{enumerate}{3}
\setlist[myenumerate]{
  label       = \arabic*. ,
  align       = left ,
  leftmargin  = 1.75em ,% = labelwidth + labelsep + labelindent
  labelwidth  = 1.5em ,
  labelindent = 0em ,
  labelsep    = .25em
}

% the following two commands are just for laziness and
% keeping the example short:
\newcommand*\longitem{%
 \item This line wraps into two lines. This line wraps into two lines.
   This line wraps into two lines. This line wraps into two lines. This
   line wraps into two lines.
}
\newcommand*\twelveitems{%
  \longitem\longitem\longitem\longitem\longitem\longitem
  \longitem\longitem\longitem\longitem\longitem\longitem
}

\begin{document}

This is the start of a paragraph. This is the start of a paragraph. This is the
start of a paragraph. This is the start of a paragraph.

\begin{myenumerate}
 \twelveitems
\end{myenumerate}

This is the start of a paragraph. This is the start of a paragraph. This is the
start of a paragraph. This is the start of a paragraph.

\end{document}
Regards
site moderator & package author
audreyk
Posts: 23
Joined: Fri Nov 14, 2008 5:57 am

Re: Long enumerated List with custom Alignment

Post by audreyk »

Your resolution worked perfectly ... thank you so much for the expert help!

Regards,
Audrey :)
Post Reply