[Tex/LaTex] Solving “overfull \vbox” in table with multirow

multirowparboxtableswarnings

This table has been causing me nothing but problems. Right now, it looks OK:

enter image description here

But it's clear the vertical spacing is not so good. "Region" is too high (which I tried to address with the [fixup] parameter of multirow: [-0.5em]). I used \parbox to get line breaking and centering of the middle columns proper. To fit my page width these columns need to line-wrap on three lines.

When I run, I get two errors for these two columns:

Overfull \vbox (5.89192pt too high) detected 
Overfull \vbox (6.57993pt too high) detected

Like I said, it looks OK, but I'd like to understand what's going on (even if I could just change table content to fix the problem, that won't tell me why it was a problem). Perhaps I'm a glutton for punishment, but after a few hours pounding away at my thesis I enjoy taking a break by debugging \LaTeX errors/warnings.

I have read several questions/answers here and tried inserting invisible rules (from a comment), \smash (which broke line-wrapping), \vphantom (which made text disappear), adding [1em] in various places of varying sizes, and several other methods.


MWE:

\documentclass{article} % The class file specifying the document structure

\usepackage{palatino} % Use the Palatino font by default
\usepackage{siunitx}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{array}
\usepackage[referable]{threeparttablex}
\usepackage{multirow}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}

\geometry{
    paper=letterpaper, % Change to letterpaper for US letter
    inner=2.5cm, % Inner margin
    outer=3.8cm, % Outer margin
    bindingoffset=.5cm, % Binding offset
    top=1.5cm, % Top margin
    bottom=1.5cm, % Bottom margin
}

\begin{document}

\begin{table}[!htb]
    \sisetup{input-decimal-markers = .,group-separator={,}, group-four-digits = true}
    \captionsetup{skip=0.5\baselineskip,size=footnotesize}
    \footnotesize
    \centering
    \begin{threeparttable}
        \begin{tabular}{L{2.8cm}*4{S[table-format=2.1]}}
            \toprule
            \multicolumn{1}{c}{\multirow{2}{*}[-0.5em]{\parbox[c]{2.7cm}{\centering \textbf{Region}}}} & 
            \multicolumn{1}{c}{\multirow{2}{*}{\parbox[c]{1.8cm}{\centering \textbf{Electric outages per month}\tnote{a}}}} &
            \multicolumn{1}{c}{\multirow{2}{*}{\parbox[c]{2.0cm}{\centering \textbf{Typical outage duration (hours)}\tnote{a}}}} & 
            \multicolumn{2}{c}{\centering\textbf{Population with electricity access}\tnote{b}}         \\  \cmidrule{4-5}
            & ~ & ~ & \multicolumn{1}{c}{\parbox[c]{1.7cm}{\centering \textbf{~~Total [\si{\percent}]}}} & \multicolumn{1}{c}{\parbox[c]{1.7cm}{\centering\textbf{~~Rural [\si{\percent}]}}} \\ [0.2cm]
            \midrule
            South Asia & 25.4 & 3.1 & 78. & 69.3 \\%
            Sub-Saharan Africa & 9.0 & 4.2 & 35.3 & 15.3 \\%
            OECD countries & 0.4 & 0.4 & 99.9 & 99.7 \\%
            \bottomrule
        \end{tabular} 
        \begin{tablenotes}
        \item[a] For commercial users only
        \item[b] For residential users only
        \end{tablenotes}
    \end{threeparttable}
    \caption[Grid statistics for selected regions]{Grid statistics for selected regions.}
    \label{tab:grid}
\end{table}

\end{document}

Note that the screenshot and MWE use the article class, but for my document I'm using a slightly modified version of the custom class MastersDoctoralThesis (but the errors are identical either way):

\documentclass[11pt,oneside,english,singlespacing,
               headsepline,chapterinoneline]
              {MastersDoctoralThesis}

Best Answer

The first argument of \multirow is not really the number of rows replaced by a single cell, but the number of lines – or equivalent thereof – which are replaced. Taking a value of 4 does the job.

I took the opportunity to simplify your code using the makecell package, and its \multirowthead command, which allows for line breaks in cells, and a common formatting. Also, I propose to have the leftmost column head left-aligned, but it's easy to change that (the default for all makecell commands is centred both vertically and horizontally).

Last point: palatino is obsolete, and has no support for maths. I replaced this package with newpx, based on the palatino clone TeX Gyre Pagella.

\documentclass{article} % The class file specifying the document structure
\usepackage{newpxtext, newpxmath} %
\usepackage{siunitx}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{array}
\usepackage[referable]{threeparttablex}
\usepackage{multirow, makecell}
\renewcommand\theadfont{\bfseries}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}

\geometry{
    paper=letterpaper, % Change to letterpaper for US letter
    inner=2.5cm, % Inner margin
    outer=3.8cm, % Outer margin
    bindingoffset=.5cm, % Binding offset
    top=1.5cm, % Top margin
    bottom=1.5cm, % Bottom margin
}

\begin{document}

\begin{table}[!htb]
    \sisetup{input-decimal-markers = .,group-separator={,}, group-four-digits = true}
    \captionsetup{skip=0.5\baselineskip,size=footnotesize}
    \footnotesize
    \centering
    \begin{threeparttable}
        \begin{tabular}{L{2.8cm}*4{S[table-format=2.1]}}
            \toprule
            \renewcommand\theadalign{lc}\multirowthead{3}{Region}&
           {\multirowthead{4}[1.3ex]{Electric\\ outages\\ per month\tnote{a}}} &
            {\multirowthead{4}[1.3ex]{Typical outage\\ duration\\ (hours)\tnote{a}}} &
            \multicolumn{2}{c}{\centering\textbf{Population with electricity access}\tnote{b}} \\%
            \addlinespace[0.5ex] \cmidrule(lr){4-5}
            & ~ & ~ & {\quad\textbf{Total [\si{\percent}]}\quad} & {\textbf{Rural [\si{\percent}]}}\\%
            \addlinespace[0.8ex]
            \midrule
            South Asia & 25.4 & 3.1 & 78. & 69.3 \\%
            Sub-Saharan Africa & 9.0 & 4.2 & 35.3 & 15.3 \\%
            OECD countries & 0.4 & 0.4 & 99.9 & 99.7 \\%
            \bottomrule
        \end{tabular}
        \begin{tablenotes}
        \item[a] For commercial users only
        \item[b] For residential users only
        \end{tablenotes}
    \end{threeparttable}
    \caption[Grid statistics for selected regions]{Grid statistics for selected regions.}
    \label{tab:grid}
\end{table}

\end{document} 

enter image description here

Related Question