2

I would like to have two lines for long description names in the description environment. The only help I could find is here. Where they have the following code.

\begin{description}
   % won't work
   \item[first line\\second line]
   % won't work
   \item[first line\newline second line]
   % will work
   \item[{\parbox[t]{3cm}{first line\\second line}}]
\end{description}

But this doesn't look nice, I have a long paragraph on the item and the second line of the paragraph starts below the second line of the item label.

  • 2
    Please show your preamble part, i.e., \documentclass{...}...\begin{document}... – MadyYuvi Nov 30 '18 at 11:40
2

For single-line item data, use \stackunder{}{}. For multi-line item data, use \smash{\stackunder{}{}}.

Also shown is the use of \smash{\Longunderstack{...\\...\\...}} in the event the label gets to be longer than 2 lines.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{lipsum}
\begin{document}
\renewcommand\stackalignment{r}% RIGHT ALIGNED STACKS
\renewcommand\stacktype{L}% MAKE STACKS OBEY FIXED BASELINESKIP
\strutlongstacks{T}% TO GET PROPER SPACING FOR SINGLE-LINE ITEMS
\begin{itemize}
   \item[\stackunder{first line}{second line}] blah blah
   \item[\smash{\stackunder{first line}{second line}}] \lipsum[4]
   \item[\smash{\Longunderstack{first\\second\\third}}] \lipsum[3]
\end{itemize}
\end{document}

enter image description here

You could add \bfseries before the stack, if you wanted it in boldface.

As Bernard notes, the title bleeds into the left margin, which is a standard behavior for itemize. The way to alleviate that is to select leftmargin that allows for the widest label:

\documentclass{article}
\usepackage[pass,showframe]{geometry}
\usepackage[usestackEOL]{stackengine}
\usepackage{lipsum,enumitem}
\begin{document}
\renewcommand\stackalignment{r}% RIGHT ALIGNED STACKS
\renewcommand\stacktype{L}% MAKE STACKS OBEY FIXED BASELINESKIP
\strutlongstacks{T}% TO GET PROPER SPACING FOR SINGLE-LINE ITEMS
\begin{itemize}[leftmargin=53pt]
   \item[\stackunder{first line}{second line}] blah blah
   \item[\smash{\stackunder{first line}{second line}}] \lipsum[4]
   \item[\smash{\Longunderstack{first\\second\\third}}] \lipsum[3]
\end{itemize}
\end{document}

enter image description here

  • The labels flow into the left margin. – Bernard Nov 30 '18 at 13:11
  • @Bernard Addressed. – Steven B. Segletes Nov 30 '18 at 13:29
  • Really beautiful! – Bernard Nov 30 '18 at 13:33
  • 1
    Thanks, this does precisely what I needed with what seems that minimal package loading and effort. – MetalMathician Dec 10 '18 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.