2

I have a description environment and would like to center the descriptions vertically w.r.t respect to the items (which are images).

\begin{description}
    \item[\pict1] - Description
\end{description}

\pict1 is rather large compared to the height of the description text. As it is, it is put at the "base line" (the bottom of the image) and I would like it to be centered.

9

I'm not sure that description is the best way do to this; I'd use

\begin{flushleft}
\sbox0{\includegraphics{pict1}}
\raisebox{-.5\height}{\usebox0}\quad
\begin{minipage}{\dimexpr\textwidth-\wd0-1em}
Description
\end{minipage}
\end{flushleft}

The main problem is in fact that the description text height is not known in advance. This could be easily made up into a new environment.

Here's an example:

enter image description here

If your descriptions are only one line long, then a different and simpler approach can be used.

\documentclass{article}

\usepackage{enumitem}
\usepackage[export]{adjustbox}

\begin{document}

\begin{description}[labelwidth=3cm]

\item[{\includegraphics[valign=c,width=2.5cm]{a}}] Description a

\item[{\includegraphics[valign=c,width=1.5cm]{b}}] Description b

\item[{\includegraphics[valign=c,width=2cm]{b}}] Description c

\end{description}

\end{document}

Adjust the parameters to description to suit you. The key is valign=c provided by adjustbox.

enter image description here

| improve this answer | |
  • The description environment is optimal in that I sort of want to do what css or wpf does. i.e., Apply a "style" to a bland environment to make it look better but otherwise keep the content the same. I have multiple item/descriptions and I'm using multicols. Everything works very simply except for the centering. – Uiy May 4 '12 at 22:41
  • @Uiy As I said, the main problem is that the description is not known in advance, but only when the next \item is found. A solution simply with \item requires to know more about your possible text and also about the width of the labels/pictures and relative alignment of the texts. – egreg May 4 '12 at 22:48
  • Why can't the description itself use the it's item to determine it the center value and then center itself in that? e.g., the description gets the previous item's height and divides by 2. This then is the "center" value that the description will use as it's center value. It seems as if your trying to center the item to the description when I want to center the description to the item. – Uiy May 4 '12 at 22:55
  • @Uiy Because the item text is not gathered as an argument. If you're willing to accept a different syntax, then it's feasible. – egreg May 4 '12 at 23:00
  • I don't mind a different syntax or having to specify the offset height of description. In my case they are all single lined text and the item height's are approximately all the same. Not an ideal solution but simply need something that will work inline with what I have(the multicols stuff). – Uiy May 4 '12 at 23:28

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.