[texhax] Label position in enumerated list
Uwe Lück
uwe.lueck at web.de
Sun Feb 18 21:06:43 CET 2007
At 15:27 16.02.07, tom sgouros wrote:
>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.
> > 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] ..
>
>Here's a hack and a recipe for hacking things like it:
...
>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.)
:) -- BIG BROTHER IS WATCHING YOU!
Below I place a legal way to do it -- with examples.
I hope you understand how to customize it.
It may be more close to what was asked for than Tom's
>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.
My code furthermore assumes that no nesting of such
environments is required. Note the similarity to the
{thebibliography} environment. Indeed,
\newenvironment*{enumileftaligned}[1][0]
{\renewcommand{\section}[5]{}\thebibliography{#1}}
{\endthebibliography}
is another hack working as well on my installation.
If you use \bibitem then in place of \item,
you can refer to items by \cite. [:)]
(Well, I haven't thought much about several such lists
in one document, and I won't any more. That package
managing several bibliographies in one document
may help.)
HTH -- Uwe.
_______________________________
\documentclass[12pt]{article}
\newcommand*{\leftaligninglabel}[1]{#1\hspace{\fill}}
%% For different behaviour with two-digit numbers,
%% comment out lines containing \leftaligninglabel.
\newenvironment*{enumileftaligned}[1][0]
{\list{[\theenumi]}{%
\settowidth{\labelwidth}{[#1]}%
\setlength{\leftmargin}{\labelwidth}%
\addtolength{\leftmargin}{\labelsep}%
\renewcommand{\makelabel}{\leftaligninglabel}%
\usecounter{enumi}}}
{\endenumerate}
\begin{document}
\noindent
Usually:
\begin{enumerate}
\item One item.
\setcounter{enumi}{9}
\item Skipped a few items.
\end{enumerate}
Left-aligned (cf. \verb|\thebibliography|):
\begin{enumileftaligned}
\item One item.
\item Another item.
\item Once again.
\end{enumileftaligned}
More than 9:
\begin{enumileftaligned}[00]
\item One item.
\item Another item.
\setcounter{enumi}{9}
\item Skipped a few items.
\end{enumileftaligned}
Or do you prefer:
\renewcommand{\leftaligninglabel}{\hspace{\fill}}
\begin{enumileftaligned}[00]
\item One item.
\item Another item.
\setcounter{enumi}{9}
\item Skipped a few items.
\end{enumileftaligned}
\end{document}
More information about the texhax
mailing list