4

I am using the description environment to give some extra reasons for the items. However, some items are obvious and don't need reasons. Leaving them empty puts a large blank line, because I have set the descriptions to go on the next line

\documentclass[12pt]{report}

\usepackage{enumitem} % configure labels of items in enumerations i.e. i), ii)
\setlist[description]{style=nextline,font=\normalfont\textbullet\space,labelindent=\parindent}

\begin{document}
\begin{description}
    \item[Obvious item]
    \item[Not so obvious] So we need a small reason, which can span multiple lines lines lines lines lines lines lines lines lines lines lines lines
    \item[Also obvious]
\end{description}
\end{document}

mwe

If I'm doing this wrong, any advice is welcome ! :) .

Edit: The ugliest hack so far is to use \item[Obvious item\vspace{-1.5em}] which seems right to my eye™️.

To add: I'm using description with nextline because this kind of respects the logical formatting and I'm thinking of improving the style later (e.g. make the term bold). This would be (I think) more difficult if I used a replacement such as itemize with manual line breaks

Maybe I could patch description to detect empty item description ?

4

Massage the body so you transform your description into itemize (and get alignment right).

\documentclass[12pt]{report}
\usepackage{environ,xparse}

\ExplSyntaxOn
\NewEnviron{ctdescription}
 {
  % remove possible \par generated by blank lines before \item
  \tl_replace_all:Nnn \BODY { \par\item } { \item }
  % add a trailing delimiter
  \tl_put_right:Nn \BODY { \ct_item_end: }
  % replace \item by \ct_item_end: \ct_item:w
  \tl_replace_all:Nnn \BODY { \item } { \ct_item_end: \ct_item:w }
  % remove the spurious leading \ct_item:w
  \tl_set:Nx \BODY { \tl_tail:N \BODY }
  % produce the environment
  \begin{itemize}\BODY\end{itemize}
 }
\cs_new_protected:Npn \ct_item:w [#1] #2 \ct_item_end:
 {
  \item #1 \tl_if_blank:nF { #2 } { \mbox{} \\ \tl_trim_spaces:n { #2 } }
 }
\ExplSyntaxOff

\begin{document}

\begin{ctdescription}
\item[Obvious item]
\item[Not so obvious] No we need a small reason, which can 
  span multiple lines lines lines lines lines lines lines 
  lines lines lines lines lines
\item[Also obvious]
\end{ctdescription}

\end{document}

Note that a trailing blank line is not allowed, but they're allowed before \item.

enter image description here

3

An even more ad-hoc proposal: why not forget about description altogether?

\documentclass[12pt]{report}

\begin{document}

\begin{itemize} 
    \item Obvious item
    \item Not so obvious \\
          So we need a small reason, which can span multiple lines lines lines lines lines lines lines lines lines lines lines lines
    \item Also obvious
\end{itemize}

\end{document}

This should produce the displayed output.

2
  • I was thinking that I do description now, as it marks the logic nicely, and then I can easier change the formatting (make the item bold, use numbers, what not). I'm curious to see if anyone proposes a \vpace{-1.5em} to be properly ad-hoc ^^ – Ciprian Tomoiagă Mar 13 '18 at 22:03
  • Sure, if it serves the structure of the rest of your document, then you'd rather keep description. Have you tried anything with vspace, yet? If so, add it to your question as an addendum and people might start from there. – thymaro Mar 13 '18 at 22:47
2

A very ad hoc proposal: forget about nextline.

\documentclass[12pt]{report}

\usepackage{enumitem} % configure labels of items in enumerations i.e. i), ii)
\setlist[description]{font=\normalfont\textbullet\space,labelindent=\parindent}

\begin{document}
\begin{description}
    \item[Obvious item]
    \item[Not so obvious]~\\ So we need a small reason, which can span multiple lines lines lines lines lines lines lines lines lines lines lines lines
    \item[Also obvious]
\end{description}
\end{document}

enter image description here

2
  • thank you, marmot ! It would be a solution if I were to start now. But I already have description in many parts, with a bit more items than the MWE, all of which require description :). The obvious item is an isolated one among many – Ciprian Tomoiagă Mar 13 '18 at 22:00
  • @CiprianTomoiagă I see. In principle my proposal would just amount to regex search and replace... – user121799 Mar 13 '18 at 23:06

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.