# Vertical centering in tabularx

I am trying to get a text to center vertically within a tabularx. For centered and bottom text it works, but it fails for top text. What am I missing here?

        \begin{tabularx}{\textwidth}{ | X | c | }
\hline
\noindent\parbox[t]{\hsize}{\includegraphics[width=5cm]{img/image001}} & top\\
\hline
\noindent\parbox[c]{\hsize}{\includegraphics[width=5cm]{img/image001}} & center\\
\hline
\noindent\parbox[b]{\hsize}{\includegraphics[width=5cm]{img/image001}} & bottom\\
\hline
\end{tabularx}


Use valign from adjustbox.

I used also margin=4pt to put some space around the image, and I inverted the column types of your table, I don't think you want an X type for a column where there are only fixed-width images.

\documentclass{article}
\usepackage{tabularx}
\usepackage{graphicx}

\begin{document}
\begin{table}\centering
\begin{tabularx}{\linewidth}{ | c | X | }
\hline
\includegraphics[width=5cm, valign=t, margin=4pt]{example-image} & top\\
\hline
\includegraphics[width=5cm, valign=c, margin=4pt]{example-image} & center\\
\hline
\includegraphics[width=5cm,valign=b, margin=4pt]{example-image} & bottom\\
\hline
\end{tabularx}
\end{table}
\end{document}


Your question may be a duplicate of this one: How to align picture top left in a table?.