5

I've been trying to create a list environment to produce something that does the following:

  1. It has a counter (like the enumerate environment).

  2. The first line of each item is an overview of the item (probably in boldface).

  3. Some items have nothing other than the first line, while others have more description. The description is aligned with the title above it.

The following was my attempt:

\newcounter{numberdesc}
\newenvironment{numberdescription}{\begin{list}{}{%
  \renewcommand{\makelabel}{\textbf{\thenumberdesc.\hfill}}}}{%
  \end{list}}
\newcommand{\descitem}[1]{\stepcounter{numberdesc}\item\textbf{#1}\newline}

\begin{numberdescription}
\descitem{First item}
  has some description below it
\descitem{Second item does not}
\descitem{Third item}
  also has description
\end{numberdescription}

but I know that this is rather crude (not least the \newline in the definition of the \item replacement).

It was suggested to me in a previous attempt that the enumitem package does what I want, but as far as I can tell this doesn't align the text of the description in the manner I want. To be specific: each item has a number and a title, and the text of the item should be aligned with the title but not the number.

I want it to produce something like the following (which was produced in a more crude manner):

enter image description here

4
  • 1
    have you seen Enumerated description list
    – cmhughes
    Feb 26, 2013 at 19:10
  • I've editted my original question to clarify that I want something that goes beyond (namely in terms of alignment) of the answers on that page. Feb 27, 2013 at 13:48
  • 1
    If I understand you correctly, you want to avoid the newline if no content appears underneath? Feb 27, 2013 at 15:17
  • Yes - I think that's what I want to do. Feb 27, 2013 at 15:58

1 Answer 1

4

A simple solution is to add \par after the heading. You can build this in as follows:

Sample output

\documentclass{article}

\newcounter{numberdesc}
\newenvironment{numberdescription}{\begin{list}{}{%
  \renewcommand{\makelabel}{\textbf{\thenumberdesc.\hfill}}}}{%
  \end{list}}
\newcommand{\descitem}[1]{\stepcounter{numberdesc}{\item\textbf{#1}\par}}

\begin{document}

\noindent Text to show alignment.
\begin{numberdescription}
\descitem{First item}
  has some description below it
\descitem{Second item does not}
\descitem{Third item}
  also has description
\descitem{Fourth item}
  has some description below it
\descitem{Fifth item does not}
\descitem{Sixth item}
  also has description
\descitem{Seventh item}
  has some description below it
\descitem{Eight item does not}
\descitem{Ninth item is so long that it fills more than one line, but
that doesn't give us problems}
also has description
\descitem{Tenth item}
  has some description below it
\end{numberdescription}

\end{document}
1
  • Thank you. A very simple solution - I clearly need to remember the \par command. Feb 28, 2013 at 11:44

You must log in to answer this question.

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