# Vertical centering with multirow and tables

I am trying to figure something out that I can't find the answer to.

I am trying to create a table where some cells in a row need to have multiple rows. I thought "multirow" would allow me to do this, which it does, but it incorrectly vertically centers the data that spans multiple rows. See the attached figure - it ends up being too high.

I realize that in the example I sent, I can just use 3 rows with the top and bottom being empty but in the case of having an even number of split rows, that method isn't possible. I also looked at the documentation for multirow and they specify that there is a finetuning parameter where you can adjust its height manually. I do not want to do this because if I am off even by a little bit it won't line up. Plus I figured there would be a better way.

Here is a MWE

\documentclass[12pt,a4paper,twoside]{report}
%\usepackage[latin1]{inputenc} % shouldn't you be using 'utf8'?
\usepackage{amsmath}
%%%\usepackage{amsfonts} % is loaded automatically by 'amssymb'
\usepackage{amssymb}
\usepackage{graphicx}

\usepackage{multirow}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1\textwidth}}

\setlength{\textheight}{9in} % Height of the main body of the text
\setlength{\topmargin}{-.5in} % .5" margin on top of page
\setlength{\footskip}{.5in}  % space between footer and bottom of body
\setlength{\textwidth}{6.25in} % width of the body of the text
\setlength{\oddsidemargin}{.25in} % 1.25" margin on the left for odd pages
\setlength{\evensidemargin}{0in} % 1.25"  margin on the right for even pages

% Marginal notes
\setlength{\marginparwidth}{.75in} % width of marginal notes
\setlength{\marginparsep}{.125in} % space between marginal notes and text
\usepackage{booktabs}

\begin{document}
\begin{table}[ht]
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{0pt}
\caption[A caption]{A caption}
\label{tab-brachy-review}
\footnotesize
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}%
M{0.1}M{0.14}M{0.13}M{0.15}M{0.13}M{0.14}M{0.085}M{0.125}}

Refs                     & Site                   & Method                  & Sample Size        & fractions        & Delay (days)       & BF and Perm & test       \\ \midrule
Janssen                  & Te                 & 1                  & 23                 & 25 / 5                     & Day 5\textsuperscript{a} & Increase    & NSC      \\ \midrule
\multirow{3}{*}{Coolens} & \multirow{3}{*}{Li} & \multirow{3}{*}{2} & \multirow{3}{*}{6} & \multirow{3}{*}{30-54 / 6} & Day 3\textsuperscript{a} & Increase    & Increase \\ \cmidrule{6-8}
&                        &                         &                    &                            & 30                       & Decrease    & NSC      \\ \cmidrule{6-8}
&                        &                         &                    &                            & 60                       & Decrease    & NSC      \\ \cmidrule{6-8}
Janssen                  & Te                 & 1                 & 23                 & 25 / 5                     & Day 5\textsuperscript{a} & Increase    & NSC      \\ \bottomrule
\end{tabular*}
\end{table}
\end{document}


First, you need to know what exactly a booktab is doing different from a plain tabular. Specifically, two spaces are added below and above rules, \belowrulesep=.65ex and \aboverulesep=.4ex. These additional vertical spaces spoil the work of \multirow, happily though, as you mentioned, there is an additional option for \multirow which can be used to compensate for this.

The rule is like this: if you have n rows in \multirow, so you need to lower the contents by n/2 * (0.65ex + 0.4ex) = n/2 * 1.05ex, or simply 0.525*n. In our case, this is 0.525*3ex = 1.5750ex. So, simply do the math or use \dimexpr to calculate this dimension and add its negative to the option for \multirow.

\documentclass[12pt,a4paper,twoside]{report}
%\usepackage[latin1]{inputenc} % shouldn't you be using 'utf8'?
\usepackage{amsmath}
%%%\usepackage{amsfonts} % is loaded automatically by 'amssymb'
\usepackage{amssymb}
\usepackage{graphicx}

\usepackage{multirow}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1\textwidth}}

\setlength{\textheight}{9in} % Height of the main body of the text
\setlength{\topmargin}{-.5in} % .5" margin on top of page
\setlength{\footskip}{.5in}  % space between footer and bottom of body
\setlength{\textwidth}{6.25in} % width of the body of the text
\setlength{\oddsidemargin}{.25in} % 1.25" margin on the left for odd pages
\setlength{\evensidemargin}{0in} % 1.25"  margin on the right for even pages

% Marginal notes
\setlength{\marginparwidth}{.75in} % width of marginal notes
\setlength{\marginparsep}{.125in} % space between marginal notes and text
\usepackage{booktabs}

\begin{document}
\begin{table}[ht]
\renewcommand{\arraystretch}{1.5}
\setlength\tabcolsep{0pt}
\caption[A caption]{A caption}
\label{tab-brachy-review}
\footnotesize
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}%
M{0.1}M{0.14}M{0.13}M{0.15}M{0.13}M{0.14}M{0.085}M{0.125}}

Refs                               & Site                          & Method                       & Sample Size                  & fractions                            & Delay (days)             & BF and Perm & test     \\ \midrule
Janssen                            & Te                            & 1                            & 23                           & 25 / 5                               & Day 5\textsuperscript{a} & Increase    & NSC      \\ \midrule
\multirow{3}{*}[-1.575ex]{Coolens} & \multirow{3}{*}[-1.575ex]{Li} & \multirow{3}{*}[-1.575ex]{2} & \multirow{3}{*}[-1.575ex]{6} & \multirow{3}{*}[-1.575ex]{30-54 / 6} & Day 3\textsuperscript{a} & Increase    & Increase \\ \cmidrule{6-8}
&                               &                              &                              &                                      & 30                       & Decrease    & NSC      \\ \cmidrule{6-8}
&                               &                              &                              &                                      & 60                       & Decrease    & NSC      \\ \cmidrule{6-8}
Janssen                            & Te                            & 1                            & 23                           & 25 / 5                               & Day 5\textsuperscript{a} & Increase    & NSC      \\ \bottomrule
\end{tabular*}
\end{table}
\end{document}


• Awesome thanks that fixed it. Two other relataed question (I am very new to latex). How do you use the \dimexpr? and also, is there a way to change those two properties you mentioned to something else for this tex document? – thatguy14 Apr 2 '19 at 1:05
• You can calculate this by, e.g., \newcommand{\LOW}{-\the\numexpr3/2*1.05ex\relax} and use the option as [\LOW]. Also, you can change the values for \belowrulesep = .65ex and \aboverulesep = .4ex by putting any value other than .65ex and .4ex. For example, you can do \belowrulesep = 0ex outside the table, this will be global. – AboAmmar Apr 2 '19 at 1:27
• Thank you for your help so far. I wanted to try and set up a "dynamic" command so that it would be automatic. I created the command \newcommand{\LOW}[1]{-\the\numexpr#1/2*1.05\relax} and tried using that by calling it: ...[\LOW{3}]{Coolens \LOW{3}} in the table but this resulted in a value of 2.05 (If i remember correctly) being displayed. In addition, it was off center (corresponding to an incorrect value being assigned). I am not sure why this is. Thanks for your help so far – thatguy14 Apr 2 '19 at 13:58