# Vertical alignment of array inside tabular

I would like to vertically align several table cells, one of which includes an array. Consider the following MWE:

\documentclass{article}

\usepackage{graphicx}
\usepackage{array}

\begin{document}

\begin{tabular}{*{5}{m{0.2\textwidth}}}
Some text &
\includegraphics[width=15mm]{example-grid-100x100pt} &
$$\left(\begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array}\right)$$ &
$$(1,0,1,0)$$ &
\rule{15mm}{15mm}
\end{tabular}

\end{document}


Which yields (green reference line added by me):

The text, image, simple inline math, and rule are all correctly aligned vertically, but the array is pushed down. Instead I would have expected the following:

Why is the array not centered vertically? What is the easiest way to fix this?

Problem is in your \rule (where it has baseline?). If you encapsulate it in a some box, to which you can define baseline, for example with help of the macro \valign from the \adjustbox, the same do for image in the second column, than all elements of tabular in p columns type will have baseline vertical centered:

\documentclass{article}
\usepackage{array}

\begin{document}
\noindent%
\begin{tabular}{*{5}{>{\centering\arraybackslash}p{\dimexpr0.2\textwidth-2\tabcolsep}}}
Some text &
\includegraphics[width=15mm,valign=c]{example-grid-100x100pt} &
$$\left(\begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array}\right)$$ &  $$(1,0,1,0)$$ & \adjustbox{valign=c}{\rule{15mm}{15mm}}
\end{tabular}
\end{document}


(red lines indicate text border)

As you can see, I also change columns width that table can fit in text area.

• Thanks, this solves my problem! Maybe it's also worth mentioning in your answer that you changed the table layout from m to p, which I overlooked at first. With m, the vertical centering is still off, but using p and \adjustbox works perfecty fine! Nov 4 '19 at 15:36
• @einbandi, you are right. I should mentioned this too. I will extend my explanation in answer asap. Nov 4 '19 at 15:40