5

There is this box that I want to place next to a description list. It should not affect the list itself. I'm using an mbox and within the mbox a vbox with a height of 0. However, it still pushes the text down. How can I prevent this?

\documentclass{article}
\usepackage{enumitem}
\begin{document}

\begin{description}[style=multiline,leftmargin=3cm]
  \item[Item 1]
  \mbox{%
    \vbox to 0cm{\hbox to 10cm{\hfill \fbox{OK}}}
   }
   \begin{minipage}{8cm}
  Here is information. This is a multiline description. We will copy
  these lines a few times. Here is information. This is a multiline description.
  We will copy these lines a few times. Here is information. This is a multiline
  description. We will copy these lines a few times. Here is information.
  \end{minipage}

  \item[Item 2]
  \mbox{%
    \vbox to 0cm{\hbox to 10cm{\hfill \fbox{Fail}}}
   }
   \begin{minipage}{8cm}
  Here is information. This is a multiline description. We will copy
  these lines a few times. Here is information. This is a multiline description.
  We will copy these lines a few times. Here is information. This is a multiline
  description. We will copy these lines a few times. Here is information. This is
  a multiline description. 
  \end{minipage}

  \item[Another item here]
  \mbox{%
    \vbox to 0cm{\hbox to 10cm{\hfill \fbox{OK}}}
   }
   \begin{minipage}{8cm}
  Here is information. This is a multiline description. We will copy
  these lines a few times. Here is information. This is a multiline description.
  We will copy these lines a few times. Here is information. This is a multiline
  description. We will copy these lines a few times. Here is information. This is
  a multiline description. We will copy these lines a few times.Here is
  information. This is a multiline description. We will copy these lines a few
  time.
  \end{minipage}

\end{description}

\end{document}

I want the first line to appear on the same line as the description label:

Showing how it should change

Any idea what should change?

1 Answer 1

7

The \vbox is typeset with a zero height, but it goes above the minipage and its reference point is at the baseline.

You could add the information inside the minipage:

\documentclass{article}
\usepackage{enumitem}

\newcommand{\OF}[1]{%
  \makebox[0pt][l]{\hspace{10cm}\fbox{#1}}%
  \ignorespaces
}

\begin{document}

\begin{description}[style=multiline,leftmargin=3cm]
\item[Item 1]
  \begin{minipage}[t]{8cm}\OF{OK}
  Here is information. This is a multiline description. We will copy
  these lines a few times. Here is information. This is a multiline description.
  We will copy these lines a few times. Here is information. This is a multiline
  description. We will copy these lines a few times. Here is information.
  \end{minipage}

  \item[Item 2]
  \begin{minipage}[t]{8cm}\OF{FAIL}
  Here is information. This is a multiline description. We will copy
  these lines a few times. Here is information. This is a multiline description.
  We will copy these lines a few times. Here is information. This is a multiline
  description. We will copy these lines a few times. Here is information. This is
  a multiline description. 
  \end{minipage}

  \item[Another item here]
  \begin{minipage}[t]{8cm}\OF{OK}
  Here is information. This is a multiline description. We will copy
  these lines a few times. Here is information. This is a multiline description.
  We will copy these lines a few times. Here is information. This is a multiline
  description. We will copy these lines a few times. Here is information. This is
  a multiline description. We will copy these lines a few times.Here is
  information. This is a multiline description. We will copy these lines a few
  time.
  \end{minipage}

\end{description}

\end{document}

enter image description here

If you want to use bigger labels, you can use

\newcommand{\OF}[1]{%
  \makebox[0pt][l]{%
    \hspace{10cm}%
    \raisebox{\dimexpr\fontcharht\font`T+\fboxsep+\fboxrule-\height}[0pt][0pt]{%
      \fbox{\vphantom{A}#1}%
    }%
  }%
  \ignorespaces
}

With \OF{\Huge OK} the label will be shifted down.

4
  • Great, thanks! I do have two other issues: if I make the 'OF' text larger then it stays on the same baseline, which means that it now seemingly is placed higher than the block of text (try using HUGE for instance). I tried vspace there but it has no impact. Any idea? Also, this doesn't seem to work if the description is very short -- can I somehow set a standard width and a minimum height for the description?
    – user
    Commented Feb 14, 2015 at 18:56
  • @user Not sure what you mean by “standard width” and “minimum height”. For the “big sized” labels, one should use adjustbox.
    – egreg
    Commented Feb 14, 2015 at 19:10
  • Thanks! I will keep trying with the misalignment, and try adjustbox for the larger size. If need be I'll add another question as not to make this too complicated in the comments.
    – user
    Commented Feb 14, 2015 at 19:17
  • @user I added code similar to what adjustbox does.
    – egreg
    Commented Feb 14, 2015 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .