# [texhax] Label position in enumerated list

tom sgouros tomfool at as220.org
Fri Feb 16 15:27:48 CET 2007

Simmie, John <john.simmie at nuigalway.ie> wrote:

> Kopka & Daly show (Guide to LaTeX 4th ed., Fig. 4.1) the various
> parameters that control the layout of an enumerated list but
> surprisingly not the actual value of the label indent.

The reason this is a pain is because of how lists are constructed.
LaTeX calculates the indent at the beginning of the text, and the label
is snuck on by counting left from that point on the page.

> I need that to be zero so that the left margin of the text and the
> labels of an enumerated list are aligned, as eg
> [1] ..
> [2] ..
>
> Is there an easy hack please?  I cannot use other packages, eg memoir or
> whatever, for this purpose ...
>

Here's a hack and a recipe for hacking things like it: find the place in
latex.ltx or article.cls that contains the code you want to modify.  (In
the hack that follows, it's the definition of enumerate.)  Copy it into
a \makeatletter\makeatother pair in your text, fidget until desired
results are acquired.  Resist the slings and arrows of those who tell
you that you are making trouble for yourself by hacking what you don't
completely understand.  (They are correct, but I assume you are already
aware of that, and have sorted through CTAN to no avail.)

See this, too: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=chngmargonfly
This is a fully-approved LaTeX-compatible way to do it, but it will be
challenging to get your labels to line up exactly on the left margin,
unless someone here can offer a trick I don't know.

But assuming you still can't make it work, try something like the
following, but remember the warnings above.  You'll have to hack
further to get rid of the periods on the numbers, but I guess that's an
exercise best left to the hacker.

-tom

\documentclass{article}

\makeatletter
\def\enumerate{%
\ifnum \@enumdepth >\thr@@\@toodeep\else
\edef\@enumctr{enum\romannumeral\the\@enumdepth}%
\expandafter
\list
\csname label\@enumctr\endcsname
{\usecounter\@enumctr\def\makelabel##1{[##1]}}%
\fi}
\let\endenumerate =\endlist
\makeatother

\begin{document}

\begin{enumerate}
\item First.  First.  First.  First.  First.  First.  First.  First.
First.  First.  First.  First.  First.  First.  First.
\item Second  Second  Second  Second  Second  Second  Second  Second
Second  Second  Second  Second  Second  Second.
\item Third.
\item Fourth.
\item Fifth.
\item Sixth.
\item Seventh.
\item Eighth.
\item Ninth.
\item Tenth.
\end{enumerate}

\end{document}

--
------------------------
tomfool at as220 dot org
http://sgouros.com
http://whatcheer.net