2

I am writing a manual using description lists to list off GUI menu items with their subordinated parameters. An undesired effect occurs when embedding lists as the description of an item of the superior list. The embedded list does not appear on the next line.

  1. I would like to know why.
  2. I would like to know how to fix it.

I tried to use \null, \phantom{a}, \vphantom{a}, and \hphantom{a} after a superior \item to no avail.

Example

\documentclass{article}
\usepackage{fontspec}
\usepackage{enumitem}
\usepackage{xparse}


\NewDocumentEnvironment{parameters}{}
    {%
    \small
    \setlist[description]{font=\tt,nosep,labelwidth=20pt,leftmargin=30pt,}
    \begin{description}
    }%
    {%
    \end{description}
    }

\begin{document}

\begin{description}%<- Superior
\item [Apple]%<- Superior
   \begin{parameters}%<- Inferior
       \item [Citris] 0%<- Inferior
       \item [ExcludeFromFridge] 1%<- Inferior
       \item [ConsumeCold]%<- Inferior
   \end{parameters}%<- Inferior
\item [Beer]%<- Superior
   \begin{parameters}%<- Inferior
       \item [Citris] 0%<- Inferior
       \item [ExcludeFromFridge] 0%<- Inferior
       \item [ConsumeCold] 1%<- Inferior
   \end{parameters}%<- Inferior
\end{description}%<- Superior

\end{document}

Output

enter image description here

Desired Output

(without DUMMY text) enter image description here

2

You don't need xparse for this case and the facilities of enumitem are best suited. I have defined a new list parameters using \newlist (of enumitem). Also same enumitem provides before key using which, we can force a new line. We have to tell TeX to change the vertical mode.

\documentclass{article}
\usepackage{fontspec}
\usepackage{enumitem}

\newlist{parameters}{description}{1}
\setlist[parameters]{before={\mbox{}\leavevmode},font=\ttfamily,nosep,labelwidth=20pt,leftmargin=30pt,}

\begin{document}

\begin{description}%<- Superior
\item [Apple]%<- Superior
   \begin{parameters}%<- Inferior
       \item [Citris] 0%<- Inferior
       \item [ExcludeFromFridge] 1%<- Inferior
       \item [ConsumeCold]%<- Inferior
   \end{parameters}%<- Inferior
\item [Beer]%<- Superior
   \begin{parameters}%<- Inferior
       \item [Citris] 0%<- Inferior
       \item [ExcludeFromFridge] 0%<- Inferior
       \item [ConsumeCold] 1%<- Inferior
   \end{parameters}%<- Inferior
\end{description}%<- Superior

\end{document}

enter image description here

  • I used xparse for fun. That has become my standard for creating commands and environments. Great that you demonstrate an alternative way to create a list environment using enumitem! Thanks! What exactly is put into the \mbox{}? It almost looks like functional programming, because I do not see a value being sent to it and it looks like I am sending a function as a parameter. – Jonathan Komar Sep 17 '15 at 11:35
  • Also, maybe you know why \topsep=0pt does not remove the white space above the list. It would be nice to control that precisely. – Jonathan Komar Sep 17 '15 at 11:43
  • @macmadness86 try negative values for topsep like topsep=-1ex. And \mbox{} is the habit that saves life. Nothing is put in to it but it starts the line. In this case it works without it. – user11232 Sep 17 '15 at 12:04

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.