1

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:

  1. At some fixed space from the end of the described term. (This is the default behavior.)
  2. At \leftmargin on the same line as the described term, if possible, or on the next line otherwise.
  3. 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?

2
  • 2
    look enumitem package. it is very powerful and flexible.
    – Zarko
    Aug 5, 2017 at 11:24
  • 1
    I second the enumitem recommendation.
    – JPi
    Aug 5, 2017 at 11:51

1 Answer 1

1

Here is a demo of the basic description styles defined by enumitem, which can be further customised (font, left margin, &c.):

\documentclass{article}%
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage[svgnames]{xcolor}
\usepackage{lipsum}

\usepackage{enumitem}
\setlist[description]{leftmargin = 12mm}

\begin{document}

‘Force next line’: 
\begin{description}[labelwidth=\textwidth]
\item[One] \lipsum[4]
\item[And another one] \lipsum[4]
\end{description}

With \verb|style=sameline|:
\newlength{\mylength}
\begin{description}[style = sameline]
\item[One] \lipsum[4]
\item[And another one] \lipsum[4]
\end{description}

\newpage

With \verb|style=nextline, font=\itshape|:
\begin{description}[style =nextline, font=\normalfont\itshape]
\item[One] \lipsum[4]
\item[And another one] \lipsum[4]
\end{description}
With \verb|style=multiline, leftmargin=25mm|:
\begin{description}[style=multiline, leftmargin =25mm, font=\sffamily\color{Tomato}]
\item[One] \lipsum[4]
\item[And another one] \lipsum[4]
\end{description}

\end{document} 

enter image description here enter image description here

2
  • What about always-force-next-line? Is that supported?
    – einpoklum
    Aug 5, 2017 at 12:29
  • It is not pre-defined, but easy to obtain. Please see my updated answer.
    – Bernard
    Aug 5, 2017 at 12:48

You must log in to answer this question.

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