4

I am listing things with descriptions and some descriptions don't quite fit in the line, making the list look less pretty. What I've currently got is just an itemize environment and it looks kinda like this

item in list: item description
another item in list:
description of the item that is too long for
the line and it goes down here
third item in list: a description that fits

What I would like to do is:

item in list:         item description
another item in list: description of the item that is too long for
                      the line and it goes down here
third item in list:   a description that fits

or

        item in list: item description
another item in list: description of the item that is too long for
                      the line and it goes down here
  third item in list: a description that fits

I tried the align environment but that did not do the trick.

I've been trying to search for a solution but I don't really know what to google.

1
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Feb 2, 2016 at 21:55

2 Answers 2

2

You could use a longtable environment. In the example below, I've chosen p for the second column to allow automatic line breaks. Set the width of the p column to suit your page layout (of which we know nothing so far).

\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{ l p{3in} } % choose suitable width for "p" column
item in list: & item description \\
another item in list: & description of the item that is too long for the line and it goes down here\\
third item in list: & a description that fits\\
\end{longtable}
\end{document}
0
5

Here are some more options, using either a tabularx or list (via enumitem) to make full use of the text block width.

enter image description here

\documentclass{article}
\usepackage{tabularx,array}
\usepackage{enumitem}
\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{}l<{:}@{\ }X@{}}
  item in list         & item description \\
  another item in list & description of the item that is too long for
                         the line and it goes down here \\
  third item in list   & a description that fits
\end{tabularx}

\bigskip

\noindent
\begin{tabularx}{\textwidth}{@{}r<{:}@{\ }X@{}}
          item in list & item description \\
  another item in list & description of the item that is too long for
                         the line and it goes down here \\
    third item in list & a description that fits
\end{tabularx}

\bigskip

\newsavebox{\descbox}
\savebox{\descbox}{\bfseries another item in list:}
\SetLabelAlign{Left}{\makebox[\wd\descbox][l]{#1}}
\begin{description}[leftmargin=\dimexpr\wd\descbox+\labelsep,align=Left]
  \item[in list:]              item description
  \item[another item in list:] description of the item that is too long for
                               the line and it goes down here
  \item[third item in list:]   a description that fits
\end{description}

\bigskip

\SetLabelAlign{Right}{\makebox[\wd\descbox][r]{#1}}
\begin{description}[leftmargin=\dimexpr\wd\descbox+\labelsep,align=Right]
  \item             [in list:] item description
  \item[another item in list:] description of the item that is too long for
                               the line and it goes down here
  \item  [third item in list:] a description that fits
\end{description}

\end{document}

The tabular-like approach (first two) won't break across the page boundary, while the list-like approach (last two) will.

All formatting can be customized to suit your needs.

You must log in to answer this question.

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