LaTeX forum ⇒ GeneralAlignment of Description List

LaTeX specific issues not fitting into one of the other forums of this category.
spee
Posts: 4
Joined: Thu Jan 28, 2010 5:50 pm

Alignment of Description List

Postby spee » Tue Feb 02, 2010 3:53 pm

I want to change the alignment of a description list so I get the following.
  1. Label is long text
  2. lab2 blalballalaa
  3. possible second rule
  4. label3 hello world

Guess it's a \renewcommand option, but can't find it.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Postby gmedina » Tue Feb 02, 2010 4:10 pm

Hi,

you can use some of the features provided by the enumitem package.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

spee
Posts: 4
Joined: Thu Jan 28, 2010 5:50 pm

Postby spee » Tue Feb 02, 2010 5:58 pm

Probably, but I prefer not adding an package (if possible).

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Postby gmedina » Tue Feb 02, 2010 8:01 pm

Hi,

you can use a list environment to define a new environment that behaves as you describe. Take a look at the following example code (a slight modification of an example given in The LaTeX Companion):

  1. \documentclass{article}
  2.  
  3. \newenvironment{mydescription}[1]
  4. {\begin{list}{}%
  5. {\renewcommand\makelabel[1]{##1:\hfill}%
  6. \settowidth\labelwidth{\makelabel{#1}}%
  7. \setlength\leftmargin{\labelwidth}
  8. \addtolength\leftmargin{\labelsep}}}
  9. {\end{list}}
  10.  
  11. \begin{document}
  12.  
  13. \begin{mydescription}{longest label}
  14. \item[label1] text text text.
  15. \item[longest label] text text text.
  16. \item[lab2] text text text text text text text text text text text text text text text text text
  17. text text text text text text text text text text text text text text.
  18. \end{mydescription}
  19.  
  20. \end{document}


The argument of the mydescription environment specifies the width of the label field (in your case, it corresponds to the widest entry).
1,1,2,3,5,8,13,21,34,55,89,144,233,...

hkarl
Posts: 3
Joined: Mon Jan 09, 2012 7:28 pm

Postby hkarl » Fri Feb 03, 2012 2:48 pm

Hi,

I've been trying to replicate this very behavior using enumitem (version 3.5.2), but abysmally. (Very confused by the enumitem manual).

This should be possible, shouldn't it?


Thanks a lot,

Holger
(Too ashamed to post my own trials, non worked...)

User avatar
Stefan Kottwitz
Site Admin
Posts: 9406
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Fri Feb 03, 2012 8:12 pm

Hi Holger,

I guess it's easier with the mdwlist package.

Stefan
Site admin

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Fri Feb 03, 2012 8:17 pm

Stefan_K wrote:[…] I guess it's easier with the mdwlist package. […]

The enumitem package should be preferred as mentioned in the CTAN entry of mdwlist.


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1


Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests