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}

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}
2
  • This is great, thanks! Can you please explain why it works? I thought m was supposed to center cells...
    – Laurenz
    Aug 29 '17 at 5: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 5:46

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.