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.

Where can I find the definition of the description environment available in beamer? I'd like to replicate it for my own needs in an article-oriented document. I'm interested in its right-left alignment features:

right-left alignment features

share|improve this question
    
BTW there is beamerarticle. –  Martin Scharrer Jul 16 '11 at 15:02
    
$ latexdef -F -c beamer description tells me: \description first defined in "/usr/local/texlive/2010/texmf-dist/tex/latex/beamer/beamerbaselocalstructure.st‌​y". –  Martin Scharrer Jul 16 '11 at 15:03
    
What about it do you want to replicate? You might be able to do enough with just enumitem or similar, rather than drawing out all the beamer code you'd need to use beamer's version... –  Seamus Jul 16 '11 at 15:04
    
I'm interested in the alignment features of the beamer description environment. –  pluton Jul 16 '11 at 15:11
add comment

2 Answers 2

up vote 6 down vote accepted

I recommend using the enumitem package which allows customizing list environments such as description. If you would edit your question specifying what's exactly desired, you could get an example.

The mdwlist package is an alternative focussing on description lists.

Here's a solution without these packages for right aligned description labels:

\documentclass{article}
\usepackage{calc}
\usepackage{xcolor}
\newcommand*{\desccolor}{blue}
\newcommand*{\widestlabel}{}
\newcommand*{\setwidestlabel}[1]{%
  \renewcommand*{\widestlabel}{#1}}
\renewcommand\descriptionlabel[1]{%
  \hspace\labelsep\parbox[t]{%
    \widthof{\widestlabel}}{\raggedleft\textcolor{\desccolor}{#1}}}
\begin{document}
\setwidestlabel{Second Item}
\begin{description}
\item[First Item] Description of first item
\item[Second Item] Description of second item
\item[Third Item] Description of third item
\item[Fourth Item] Description of fourth item
\end{description}
\end{document}

enter image description here

share|improve this answer
    
Sometimes it really sucks that TeX is inherently one-pass so you can't automatically determine the widest label. That is, without doing some really ugly stuff involving yet another auxiliary file. Nice solution though. Probably for descriptions longer than one line a somewhat more complicated solution ought to be invoked, however, to indent following lines correctly. –  Christian Jun 11 '12 at 18:02
1  
@Christian: It is relative simple to run two pass algorithms in TeX without the need for an auxiliary file. In fact, environments like align and tablularx do that. The fact that the item environment does not do so is a design decision and not an inherent limitation of TeX. For a counter example, see my solution. –  Aditya Sep 7 '13 at 14:56
add comment

This answer is just to illustrate that it is possible to automatically calculate the width of the widest label. In ConTeXt this is done by passing fit,broad parameter to \setupitemize. For example:

\defineitemgroup
  [leftdescription]
  [
    distance=0.5em,
    color=blue,
    itemalign=flushright,
  ]

\setupitemgroup
  [leftdescription]
  [fit,broad]

\starttext


Some text before the list
\startleftdescription
  \sym{First Item} Description of first item
  \sym{Second Item} Description of second item
  \sym{Third Item} Description of third item
  \sym{Fourth Item} Description of fourth item
  \sym{Fifth Item} This is to show that the indentation 
      of the subsequent lines is done correctly. 
\stopleftdescription
Some text after the list

\stoptext

which gives

enter image description here

share|improve this answer
add comment

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.