1

I'm trying to get two multirows separated by several columns, but it wants to add an extra row in the table. My code is:

\documentclass[]{article}
\usepackage{multirow,booktabs}
\begin{document}
\begin{table}[!htbp]
    \begin{center}
     \caption{Stuff.}
      \begin{tabular}{cc|ccc|cc|ccc}
         \toprule
         \multicolumn{5}{c|}{Single Smoothing (SS)}&\multicolumn{5}{c}{Double Smoothing (DS)}\\
         \midrule
Measure &   Method &    $h=1$   &   $h=6$   &   $h=12$  &   Measure &   Method  &   $h=1$   &   $h=6$   &   $h=12$  \\
\midrule
\multirow{4}{*}{sME}    &&&&&   \multirow{4}{*}{sME}    \\
    &   SS  &   -0.312  &   -8.605  &   -3.342  &       &   DS  &   -0.315  &   -0.175  &   -0.238  \\
  & Mean    &   -0.664  &   0.462   &   -0.543  &     & Mean    &   -0.484  &   -0.290  &   -0.308  \\
    &   Naive   &   0.064   &   -0.433  &   -0.589  &       &   Naive   &   -1.364  &   -0.786  &   0.108   \\
    &   Autobox &   -0.578  &   -1.947  &   -0.702  &       &   Autobox &   -1.784  &   -0.201  &   -0.294\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}

The out put looks like this, but I don't want the extra row. enter image description here

Angus
  • 211

2 Answers2

2

You get the extra row because you didn't put any content in the row with the \multirows. Try this:

\documentclass[]{article}
\usepackage{multirow,booktabs}
\begin{document}
\begin{table}[!htbp]
    \begin{center}
     \caption{Stuff.}
      \begin{tabular}{cc|ccc|cc|ccc}
         \toprule
         \multicolumn{5}{c|}{Single Smoothing (SS)}&\multicolumn{5}{c}{Double Smoothing (DS)}\\
         \midrule
         Measure &   Method &    $h=1$   &   $h=6$   &   $h=12$  &   Measure &   Method  &   $h=1$   &   $h=6$   &   $h=12$  \\
         \midrule
         \multirow{4}{*}{sME} & SS & -0.312  & -8.605 & -3.342 & \multirow{4}{*}{sME} &   DS  &   -0.315  &   -0.175  &   -0.238  \\
             % &   SS  &   -0.312  &   -8.605  &   -3.342  &       &   DS  &   -0.315  &   -0.175  &   -0.238  \\
           & Mean    &   -0.664  &   0.462   &   -0.543  &     & Mean    &   -0.484  &   -0.290  &   -0.308  \\
             &   Naive   &   0.064   &   -0.433  &   -0.589  &       &   Naive   &   -1.364  &   -0.786  &   0.108   \\
             &   Autobox &   -0.578  &   -1.947  &   -0.702  &       &   Autobox &   -1.784  &   -0.201  &   -0.294\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}

enter image description here


P.S.: Are you sure you want those vertical lines? The booktabs package emphasizes that you shouldn't. Here's an alternative without them:

enter image description here

\documentclass[]{article}
\usepackage{multirow,booktabs}
\begin{document}
\begin{table}[!htbp]
    \begin{center}
     \caption{Stuff.}
      \begin{tabular}{cccccccccc}
         \toprule
         \multicolumn{5}{c}{Single Smoothing (SS)}&\multicolumn{5}{c}{Double Smoothing (DS)}\\
         \cmidrule(lr){1-5} \cmidrule(lr){6-10}
         Measure &   Method &    $h=1$   &   $h=6$   &   $h=12$  &   Measure &   Method  &   $h=1$   &   $h=6$   &   $h=12$  \\
         \cmidrule(lr){1-5} \cmidrule(lr){6-10}
         \multirow{4}{*}{sME} & SS & -0.312  & -8.605 & -3.342 & \multirow{4}{*}{sME} &   DS  &   -0.315  &   -0.175  &   -0.238  \\
             % &   SS  &   -0.312  &   -8.605  &   -3.342  &       &   DS  &   -0.315  &   -0.175  &   -0.238  \\
           & Mean    &   -0.664  &   0.462   &   -0.543  &     & Mean    &   -0.484  &   -0.290  &   -0.308  \\
             &   Naive   &   0.064   &   -0.433  &   -0.589  &       &   Naive   &   -1.364  &   -0.786  &   0.108   \\
             &   Autobox &   -0.578  &   -1.947  &   -0.702  &       &   Autobox &   -1.784  &   -0.201  &   -0.294\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}

You can say \cmidrule(l){i-j} or \cmidrule(r){i-j} or \cmidrule(lr){i-j} to shorten the \cmidrule on the left, on the right, or on both sides respectively.

2

I propose these layout improvements: splitting the table in two subtables, and using siunitx for a better formatting of the numbers in columns 3 to 5:

\documentclass[]{article}
\usepackage[showframe]{geometry}
\usepackage{multirow,booktabs, subcaption}
\usepackage{siunitx}

\begin{document}
\begin{table}[!htbp]
\centering\setlength{\tabcolsep}{4pt}
\sisetup{table-format=-1.3, table-number-alignment=center}
     \caption{Stuff.}
\noindent\begin{subtable}{0.48\linewidth}\centering
\caption{Single Smoothing (SS)}
      \begin{tabular}{cc*{3}{S}}
         \toprule
         Measure & Method & {$h=1$} & {$h=6$} & {$h=12$} \\
         \midrule
         \multirow{4}{*}{sME} & SS & -0.312 & -8.605 & -3.342 \\
           & Mean & -0.664 & 0.462 & -0.543 \\
             & Naive & 0.064 & -0.433 & -0.589 \\
             & Autobox & -0.578 & -1.947 & -0.702 \\
\bottomrule
\end{tabular}
\end{subtable}
\hfill
\begin{subtable}{0.48\linewidth}\centering
\caption{Double Smoothing (DS)}
 \begin{tabular}{cc*{3}{S}}
 \toprule
 Measure & Method & {$h=1$} & {$h=6$} & {$h=12$} \\
 \midrule
 \multirow{4}{*}{sME} & DS & -0.315 & -0.175 & -0.238 \\
  & Mean & -0.484 & -0.290 & -0.308 \\
   & Naive & -1.364 & -0.786 & 0.108 \\
   & Autobox & -1.784 & -0.201 & -0.294\\
\bottomrule
\end{tabular}
\end{subtable}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350