3

I would like to create a description enumeration which looks like the following:

keyword 1: Short Description of the keyword
           A characterization of the keyword
keyword 2: Short Description of the keyword
           A characterization of the keyword

As an example:

Animal 1: Lion
          A lion is ...
Animal 2: Elephant
          An elephant is ...

I tried the following

\begin{description}
    \item[Animal1: Lion]\hfill \\
    A lion is ...
    \item[Animal2: Elephant]\hfill \\
    An elephant is ...
\end{description}

The problem is that the text "A lion is ..." is not aligned with the word "Lion".

Can you give me some advise how to create such an environment where I can give the item command a second parameter for the short description which is then correctly aligned with the characterization text? By the way I'm using the koma class scrbook.

0

1 Answer 1

3

Taken from this great answer:

% arara: pdflatex 

\documentclass{scrbook}
\usepackage{calc}
\makeatletter
\newcommand{\DESCRIPTION@original@item}{}
\let\DESCRIPTION@original@item\item
\newcommand*{\DESCRIPTION@envir}{DESCRIPTION}
\newlength{\DESCRIPTION@totalleftmargin}
\newlength{\DESCRIPTION@linewidth}
\newcommand{\DESCRIPTION@makelabel}[1]{\llap{#1}}%
\newcommand{\DESCRIPTION@item}[1][]{%
  \setlength{\@totalleftmargin}%
       {\DESCRIPTION@totalleftmargin+\widthof{\textbf{#1 }}-\leftmargin}%
  \setlength{\linewidth}
       {\DESCRIPTION@linewidth-\widthof{\textbf{#1 }}+\leftmargin}%
  \par\parshape \@ne \@totalleftmargin \linewidth
  \DESCRIPTION@original@item[\textbf{#1}]%
}
\newenvironment{DESCRIPTION}
  {\list{}{\setlength{\labelwidth}{0cm}%
           \let\makelabel\DESCRIPTION@makelabel}%
   \setlength{\DESCRIPTION@totalleftmargin}{\@totalleftmargin}%
   \setlength{\DESCRIPTION@linewidth}{\linewidth}%
   \renewcommand{\item}{\ifx\@currenvir\DESCRIPTION@envir
                           \expandafter\DESCRIPTION@item
                        \else
                           \expandafter\DESCRIPTION@original@item
                        \fi}}
  {\endlist}
\makeatother
\usepackage{blindtext}

\begin{document}
\begin{DESCRIPTION}
    \item[Animal1:] \textbf{Lion}\\
    A lion is ... \blindtext
    \item[Animal2:] \textbf{Elephant}\\
        An elephant is ...
\end{DESCRIPTION}
\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged .