# Tabular environment - text vertically positions itself by bottom of tikz picture in adjacent cell

I would like to get my text (actually a matrix) to vertically center itself in its cell. Instead, it centers itself based on where the bottom of the tikz picture in the adjacent cell lies. This adds unnecessary height to a table I would like to eliminate. Is there any way to force the text column to align with the center of the tikz picture or to ignore the tikz picture entirely?

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\pic}{
{\centering
\begin{tikzpicture}[x=1cm,y=1cm]
\useasboundingbox (0,.5) rectangle (3, -2);
\draw (current bounding box.north east) -- (current bounding box.north west) -- (current bounding box.south west) -- (current bounding box.south east) -- cycle;
\end{tikzpicture}}
}

\begin{document}
\begin{tabular}{| c | c | c |} \hline
Initial Pic             &   Final Pic & U \\ \hline
\pic    &   \pic    & \\ \hline
\pic    &   \pic    &                   $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\pic    &   that    &
$\text{U} = .5 \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
this    & that      &               $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\end{tabular}
\end{document}


You can use baseline=(current bounding box.center) to achieve the desired alignment as shown in the following code:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\pic}{
{\centering
\begin{tikzpicture}[x=1cm,y=1cm,baseline=(current bounding box.center)]
\useasboundingbox (0,.5) rectangle (3, -2);
\draw (current bounding box.north east) -- (current bounding box.north west) -- (current bounding box.south west) -- (current bounding box.south east) -- cycle;
\end{tikzpicture}}
}

\begin{document}
\begin{tabular}{| c | c | c |} \hline
Initial Pic             &   Final Pic & U \\ \hline
\pic    &   \pic    & \\ \hline
\pic    &   \pic    &                   $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\pic    &   that    &
$\text{U} = .5 \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
this    & that      &               $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\end{tabular}
\end{document}


As the border of the image now overlaps with the horizontal lines, you might want to add some extra vertical space (as done here using the cellspace package):

\documentclass[12pt]{article}
\usepackage{amsmath}

\usepackage{cellspace}
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{6pt}

\usepackage{tikz}
\newcommand{\pic}{
{\centering
\begin{tikzpicture}[x=1cm,y=1cm,baseline=(current bounding box.center)]
\useasboundingbox (0,.5) rectangle (3, -2);
\draw (current bounding box.north east) -- (current bounding box.north west) -- (current bounding box.south west) -- (current bounding box.south east) -- cycle;
\end{tikzpicture}}
}

\begin{document}
\begin{tabular}{| Sc | Sc | Sc |} \hline
Initial Pic             &   Final Pic & U \\ \hline
\pic    &   \pic    & \\ \hline
\pic    &   \pic    &                   $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\pic    &   that    &
$\text{U} = .5 \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
this    & that      &               $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\end{tabular}
\end{document}


A fix with an optional argument for the baseline of the tikzpicture:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\pic}[1][-17pt]
{\centering
\begin{tikzpicture}[x=1cm,y=1cm,baseline=#1]
\useasboundingbox (0,.5) rectangle (3, -2);
\draw (current bounding box.north east) -- (current bounding box.north west) -- (current bounding box.south west) -- (current bounding box.south east) -- cycle;
\end{tikzpicture}%
}

\begin{document}
\begin{tabular}{| c | c | c |} \hline
Initial Pic             &   Final Pic & U \\ \hline
\pic    &   \pic    & \\ \hline
\pic    &   \pic    &                   $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\pic[-25pt]    &   that    &
$\text{U} = .5 \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
this    & that      &               $\text{U} = \begin{bmatrix} 1 & i & 1 & -i \\ -i & 1 & i & 1 \\ 1 & -i & 1 & i \\ i & 1 & -i & 1 \end{bmatrix}$ \\ \hline
\end{tabular}
\end{document}