2

I have a longtable with some longer text in one column and an image in another column. I need the image to be vertically centered. How can I achieve this?

\documentclass{article}

\usepackage{mwe} % blindtext, example image
\usepackage{longtable}
\usepackage{array} % for m column type

\begin{document}

\begin{longtable}{|p{5cm}|m{2cm}|}
    \blindtext &
    \includegraphics[width=\linewidth]{example-image-a}
\end{longtable}

\end{document}

Laurenz
  • 273

1 Answers1

1

enter image description here

\documentclass{article}

\usepackage{mwe} % blindtext, example image
\usepackage{longtable}
\usepackage{array} % for m column type

\begin{document}

\begin{longtable}{|m{5cm}|p{2cm}|}% <-- changed
    \blindtext &
    \includegraphics[width=\linewidth]{example-image-a}
\end{longtable}

\end{document}
Zarko
  • 296,517
  • This is great, thanks! Can you please explain why it works? I thought m was supposed to center cells... – Laurenz Aug 29 '17 at 05:36
  • yes, but to baseline of cells in neighborhood colums. so in your case the baseline of the first cell (p type) was on the top ... i only move it to vertical center (m type). – Zarko Aug 29 '17 at 05:46