# Vertical centering of multirow cell when using equations inside table

I'm trying to center vertically the first column of this table. As I'm using multirow, the text from the first column should get between matrix "A" and "B".

If I substitute the equations from the second column for any random text, the vertical centering of the first one works. So I guess it's something related to the presence of the equations.

\documentclass[a4paper,12pt]{report}

\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{table}[htbp]
\centering
\caption{Models}
\begin{tabular}{C{1.5cm}C{6cm}}
\toprule

Model & Matrix \\
\midrule
\multirow{2}[0]{*}{Model 1}    & ${\vbox{ $$A=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$} }$\\
& ${\vbox{ $$B=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$ } }$\\
\multirow{2}[0]{*}{Model 2}    & ${\vbox{ $$A=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$ } }$\\
& ${\vbox{ $$B=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$ } }$\\
\bottomrule
\end{tabular}%
\end{table}%

\end{document}

• It doesn't work with paragraphs, rules, or anything not a standard array strut in size. Feb 9 '17 at 15:21

The easiest and most general solution is to overlay the text midway between two \tikzmarks. If you actually want all that space between equations, simply replace \mathbox with \vbox.

\documentclass[a4paper,12pt]{report}

\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\newcommand{\mathbox}[1]{\bgroup
\abovedisplayskip=0pt
\belowdisplayskip=0pt
\mbox{\vbox{#1}}%
\egroup}

\begin{document}

\begin{table}[htbp]
\centering
\caption{Models}
\begin{tabular}{C{1.5cm}C{6cm}}
\toprule
Model & Matrix \\
\midrule
\tikzmark{row1} &\mathbox{$$A=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$}\\
\tikzmark{row2} &\mathbox{$$B=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$}\\
\bottomrule
\end{tabular}\tikz[remember picture,overlay]{\path (pic cs:row1)--(pic cs:row2)
node[midway, text width=1.5cm, anchor=base]{Model 1};}%