Consider a description list in which the body of a description is indented by some amount (\leftmargin
I think). There are 3 obvious options for where the text of the first line of the description can begin:
- At some fixed space from the end of the described term. (This is the default behavior.)
- At
\leftmargin
on the same line as the described term, if possible, or on the next line otherwise. - Always at
\leftmargin
on the line below the defined term.
Here are option 1 and two ways of effecting option 3:
\documentclass{article}
\usepackage{lipsum}
\usepackage{calc}
\newcommand{\filledterm}[1]{%
#1%
\setlength{\mylength}{\textwidth-\widthof{#1}}%
\hspace{\mylength}
}
\begin{document}
Plain vanilla:
\begin{description}
\item[One] \lipsum[4]
\item[And another one] \lipsum[4]
\end{description}
With \verb|\mbox{}\\|:
\begin{description}
\item[One]\mbox{}\\ \lipsum[4]
\item[And another one]\mbox{}\\ \lipsum[4]
\end{description}
With filling:
\newlength{\mylength}
\begin{description}
\item[\filledterm{One}] \lipsum[4]
\item[\filledterm{And another one}] \lipsum[4]
\end{description}
\end{document}
Option 2 is a bit trickier, I guess I would need some kind of conditional in there.
Anyway, my question is - how can I actually avoid using these ugly hacks in each list separately? I want to be able to have some of my description lists behave one way, and others a different way. Do I need to patch the \item command somehow? ... but if I do that, it will effect all lists. I suppose I could use an \itemwrapper
command in the relevant lists instead of \item
, but I'd actually rather avoid that.
What would be a convenient-to-use (and hopefully elegant) way to let me choose which kind of placement I like for my description list?
enumitem
package. it is very powerful and flexible.enumitem
recommendation.