4

I'm trying to create a variant of the description environment that coerces any present description to be on the next line. I can't seem to get the vertical spacing right when there's no description for the term, however.

If an item in a list doesn't have any body text, how can I forgo its corresponding vskip?

MWE

\documentclass{article}
\usepackage{mwe}
\usepackage{enumitem}
\newlist{classlist}{description}{1}
\setlist[classlist]{
  before     = \itshape\small,
  font       = \normalfont,
  leftmargin = 1em,
  labelsep   = 1em,
  itemsep    = 0pt,
  style      = nextline,
  labelwidth = 0pt % always bump to next line
}

\def\descr{Class description.  More class description.  There's so
  much description here.  It's very descriptive.  This class will be
  the most descriptive.  It'll be great.}

\begin{document}
\lipsum[1]
\begin{classlist}
  \item[Class Name]
  \item[Class Name] \descr
  \item[Class Name]
  \item[Class Name]
\end{classlist}

% This version displays correctly, but...
\begin{description}[                    %
  font=\normalfont,                  %
  leftmargin=1em,                 %
  labelsep=1em,                %
  before=\itshape\small,    %
  itemsep=0pt            %
]                     %
\item[Class Name]  % i'd like to avoid this manual ~\newline cruft
\item[Class Name] ~\newline \descr
\item[Class Name]
\item[Class Name]
\end{description}
\end{document}

output

2

Enlarge the labelwidth so that the label takes the whole first line:

\documentclass{article}
\usepackage{mwe}
\usepackage{enumitem}
\newlist{classlist}{description}{1}
\setlist[classlist]{
  before     = \itshape\small,
  font       = \normalfont,
  leftmargin = 1em,
  labelsep   = 1em,
  itemsep    = 0pt,
  labelwidth = \dimexpr\linewidth-1em % always bump to next line
}

\def\descr{Class description.  More class description.  There's so
  much description here.  It's very descriptive.  This class will be
  the most descriptive.  It'll be great.}

\begin{document}
\lipsum[1]
\begin{classlist}
  \item[Class Name]
  \item[Class Name] \descr
  \item[Class Name]
  \item[Class Name]
\end{classlist}

\end{document}

enter image description here

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.