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.

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

share|improve this question
1  
have you seen Enumerated description list –  cmhughes Feb 26 '13 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. –  Martyn Quick Feb 27 '13 at 13:48
1  
If I understand you correctly, you want to avoid the newline if no content appears underneath? –  Sean Allred Feb 27 '13 at 15:17
    
Yes - I think that's what I want to do. –  Martyn Quick Feb 27 '13 at 15:58
add comment

1 Answer

up vote 4 down vote accepted

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}
share|improve this answer
    
Thank you. A very simple solution - I clearly need to remember the \par command. –  Martyn Quick Feb 28 '13 at 11:44
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.