0

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.

enter image description here

\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{   \begin{equation}
                A=\begin{bmatrix}
                1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
                \end{bmatrix}
                \end{equation}} }$\\
        & ${\vbox{      \begin{equation}
                B=\begin{bmatrix}
                1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
                \end{bmatrix}
                \end{equation} } }$\\
        \multirow{2}[0]{*}{Model 2}    & ${\vbox{       \begin{equation}
                A=\begin{bmatrix}
                1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
                \end{bmatrix}
                \end{equation} } }$\\
        & ${\vbox{      \begin{equation}
                B=\begin{bmatrix}
                1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
                \end{bmatrix}
                \end{equation} } }$\\
        \bottomrule
    \end{tabular}%
    \label{tab:addlabel}%
\end{table}%

\end{document}
  • It doesn't work with paragraphs, rules, or anything not a standard array strut in size. – John Kormylo Feb 9 '17 at 15:21
1

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{\begin{equation}
                A=\begin{bmatrix}
                1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
                \end{bmatrix}
                \end{equation}}\\
        \tikzmark{row2} &\mathbox{\begin{equation}
                B=\begin{bmatrix}
                1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
                \end{bmatrix}
                \end{equation}}\\
        \bottomrule
    \end{tabular}\tikz[remember picture,overlay]{\path (pic cs:row1)--(pic cs:row2)
        node[midway, text width=1.5cm, anchor=base]{Model 1};}%

    \label{tab:addlabel}%
\end{table}%

\end{document}

demo

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.