3

I'm working on a technical guide, and I have a list of descriptions of different commands that can be run. Some of these commands have aliases or alternative invocations, and I want them to have the same description body. Using the enumitem package, I've managed to customize this to look the way I want. What I have looks like the following:

\documentclass{book}

\usepackage{lipsum}
\usepackage{enumitem}

\SetLabelAlign{parleft}{\parbox[t]\textwidth{#1}}

\begin{document}

\begin{description}[style=nextline,labelindent=0em,align=parleft]
\item[There's just one phrase, notice hanging characters]
    Here Is The Definition Of The Phrase. \lipsum[11]
\item[This is the first phrase \newline Notice hanging characters in the second phrase]
    Here Is The Definition Of The Phrase. \lipsum[47]
\end{description}

\end{document}

Items that just have a single line look perfectly fine to me, but when there are multiple lines, the spacing between the last line in the \item and the following description is much shorter than the spacing between the lines inside the item and between single-line items and their descriptions:

Shorter interline spacing for multi-line text

I have two questions:

  • To help my understanding of TeX, why is the space after the \parbox that contains a single line correct, but the space after the one with two lines is not?
  • How can I fix this so that the space after the last line in every \item to the description is equivalent?

Note that this document is auto-generated, so a solution that doesn't require manual intervention for each multi-line item is preferred, but I can customize the generation as needed.

Thanks in advance!

  • @Zarko \parbox[<vertical placement>]{<width>}{<contents>}, but isn't it? – cfr May 15 '16 at 1:18
  • Yes, if you use parboc alone. My idea was to correct determine parobx width, a content is given by \item, as far as I understand enumitem's options. I'm not sure anymore, I need to check documentation (but not tonight, I need some sleep :-) ) – Zarko May 15 '16 at 1:22
3

This might be a way of achieving what you want:

\documentclass{book}
\usepackage{lipsum}
\usepackage{enumitem}
\SetLabelAlign{parleft}{\parbox[t]\textwidth{#1\smallskip}}
\begin{document}
\begin{description}[style=nextline,labelindent=0em,align=parleft]
  \item[There's just one phrase, notice hanging characters]
  Here Is The Definition Of The Phrase. \lipsum[11]
  \item[This is the first phrase  \newline Notice hanging characters in the second phrase]
  Here Is The Definition Of The Phrase. \lipsum[47]
\end{description}
\end{document}

wide multiline boxed labels

  • Thanks, that seems to fix it! After reading about shrinking/stretching in this answer tex.stackexchange.com/a/41488/105633 I think I understand why this change works and doesn't make the single-line items look like they have too much space, but I'm still confused about why the \parbox didn't have any space after it originally. – argentpyro May 15 '16 at 3:30
  • There's something odd going on with the way enumitem is handling \parbox which I don't understand. I wouldn't have expected Zarko's suggestions to work at all without error. Yet they do in this specific context. (They don't do what you wanted, but they don't give errors.) So I'm a bit confused about what's happening. – cfr May 15 '16 at 15:45
3

Adding a \vskip\partopsep seem to work:

\documentclass{book}

\usepackage{lipsum}
\usepackage{enumitem}

\SetLabelAlign{parleft}{\parbox[t]\textwidth{#1\vskip\partopsep}}

\begin{document}

\begin{description}[style=unboxed,labelindent=0em,align=parleft]
\item[There's just one phrase, notice hanging characters]
    Here Is The Definition Of The Phrase. \lipsum[11]
\item[This is the first phrase \newline Notice hanging characters in the second phrase]
    Here Is The Definition Of The Phrase. \lipsum[47]
\end{description}

\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.