Text FormattingFormatting Long Labels in Description List

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
cazz_
Posts: 2
Joined: Wed Apr 11, 2012 7:54 pm

Formatting Long Labels in Description List

Post by cazz_ »

Consider the following minimal working example.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}

\begin{document}
\begin{description}
\item[Very long header that extends well beyond the margins of the document which is really annoying] A somewhat long description that goes with the title.
\end{description}
\end{document}
The header of the sole item in the description list of the PDF document resulting from compiling the TeX code with PDFLaTeX, exceeds well beyond the right margin. Is there some way I can force the header to obey the margins? That is, retain the formatting of the header, but move the part of the header that exceeds the margin onto the next line?
Last edited by localghost on Wed Apr 11, 2012 8:43 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Formatting Long Labels in Description List

Post by Juanjo »

Try the enumitem package:

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{enumitem}
\begin{document}
\begin{description}[style=unboxed]
\item[Very long header that extends well beyond the margins of the document which is really annoying] A somewhat long description that goes with the title.
\end{description}
\end{document}
There other options you can use instead of "unboxed" which, perhaps, may suit your needs even better.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
cazz_
Posts: 2
Joined: Wed Apr 11, 2012 7:54 pm

Re: Formatting Long Labels in Description List

Post by cazz_ »

Fantastic. Thanks a lot.
Post Reply