Text FormattingAlignment in \enumerate list

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Alignment in \enumerate list

Post by svend_tveskaeg »

Hi all.

Consider the following example:

Code: Select all

\documentclass{article}

\usepackage[danish]{babel}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}[label={\footnotesize\textbullet},leftmargin=*,itemsep=0pt,labelsep=12pt]
  \item Baumann, Zygmunt: \quad Sociologisk perspektiv.
  \item Bjerg, Jens:      \quad Idehistorisk perspektiv.
  \item Borgnakke, Karen: \quad P{\ae}dagogisk perspektiv.
\end{enumerate}

\end{document}
I would like to vertically align (to the left) the words "Sociologisk," "Idehistorisk," and "Pædagogisk" relative to the longest of them. (I have a much long list in my `real' document.) How do I do that?

Thank you in advance!
Last edited by svend_tveskaeg on Tue Apr 26, 2011 7:40 pm, 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)

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Alignment in \enumerate list

Post by localghost »

Why the enumerate environment when you only have unnumbered items? Since the objects that are to be aligned are not part of the label, you have to put them in a special box. Alignment with \makebox could be done by two methods.

Code: Select all

\documentclass[11pt,a4paper,danish]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{enumitem}

\begin{document}
  \begin{itemize}[leftmargin=*,itemsep=0pt,labelsep=12pt]
    \item \makebox[10em][l]{Baumann, Zygmunt:} Sociologisk perspektiv.
    \item \makebox[10em][l]{Bjerg, Jens:} Idehistorisk perspektiv.
    \item \makebox[10em][l]{Borgnakke, Karen:} P{\ae}dagogisk perspektiv.
  \end{itemize}
  \begin{itemize}[leftmargin=*,itemsep=0pt,labelsep=12pt]
    \item \makebox[9em][l]{Baumann, Zygmunt}:\quad Sociologisk perspektiv.
    \item \makebox[9em][l]{Bjerg, Jens}:\quad Idehistorisk perspektiv.
    \item \makebox[9em][l]{Borgnakke, Karen}:\quad P{\ae}dagogisk perspektiv.
  \end{itemize}
\end{document}

Thorsten
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Alignment in \enumerate list

Post by svend_tveskaeg »

It works fine!

The enumerate environment was because I didn't pay proper attention to what I was doing. :(

Is is possible to automatically calculate the length of the longest names from the list (Baumann, Zygmunt, ect.) + an \quad space and left adjust it at the same time, so that I don't have to write [<length>][l] every time?

I should have written that in the initial post; sorry!

Thank you!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Alignment in \enumerate list

Post by Stefan Kottwitz »

Hi,

you could use tables for that. In contrast to lists, it offers easy ways to control the alignment. If you would consider that way, perhaps have a look at Creating tables in LaTeX for examples and explanation.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Alignment in \enumerate list

Post by localghost »

As Stefan already suggested, a table would be the better choice.

Code: Select all

\documentclass[11pt,a4paper,danish]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{array}

\begin{document}
  \begin{tabular}{@{}>{\textbullet}cll@{}}
    & Baumann, Zygmunt: & Sociologisk perspektiv. \\
    & Bjerg, Jens:      & Idehistorisk perspektiv. \\
    & Borgnakke, Karen: & P{\ae}dagogisk perspektiv.
  \end{tabular}
\end{document}
Note that I used the array package to automatically fill the first column with bullets. The @{} on both sides is to eliminate additional horizontal space caused by the length \tabcolsep which is inserted before and after a table column.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Alignment in \enumerate list

Post by svend_tveskaeg »

@Stefan,Thorsten:

Thank you very much! This is exactly what I want.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply