Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This forum thread is exactly what I'm looking for. I want my description environment to produce this:

Label is long   text 
lab2            blalballalaa
label3          possible second rule
label four      hello world

Someone offered this:

\newenvironment{mydescription}[1]                                                
  {\begin{list}{}%
   {\renewcommand\makelabel[1]{##1:\hfill}%
   \settowidth\labelwidth{\makelabel{#1}}%
   \setlength\leftmargin{\labelwidth}
   \addtolength\leftmargin{\labelsep}}}
  {\end{list}}

Which works great (the parameter is the longest label), except I think the enumitem should be able to do this. Unfortunately, the documentation for it is extremely confusing to me. Could someone show me how to achieve the same result with enumitem?

share|improve this question

1 Answer 1

up vote 18 down vote accepted

This is one possibility:

\documentclass{article}  
\usepackage{calc}  
\usepackage{enumitem}  

\begin{document}

\begin{description}[leftmargin=!,labelwidth=\widthof{\bfseries The longest label}]
  \item[The longest label] text
  \item[Short]  long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
\end{description}

\end{document}

enter image description here

share|improve this answer
    
Works great, thanks :-) –  Mk12 Aug 18 '12 at 22:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.