[Tex/LaTex] How to merge cells correctlly

tables

I have a table and need to merge two cells in one.

enter image description here
My code is below:

\begin{document}
\begin{table}[]
\centering \caption {caption}
\label{tab:boot-var}
\begin{tabular}{|c|r|r|r|r|r|r|r|r|r|r|r|r|} \hline
%
\multirow{2}{*}{$\alpha$} &
\multicolumn{3}{c|}{$\overline{\emph{VaR}}_\alpha \times 10^{-2}$}
& \multicolumn{3}{c|}{$\Delta \times 10^{-3}$} &
\multicolumn{3}{c|}{$SD \times 10^{-2}$} &
\multicolumn{3}{c|}{$RMSE \times 10^{-2}$} \\ \cline{2-13}
 & \multicolumn{1}{c|}{$C_G$} & \multicolumn{1}{c|}{$C_t$} & \multicolumn{1}{c|}{$C_R$} & \multicolumn{1}{c|}{$C_G$} & \multicolumn{1}{c|}{$C_t$} & \multicolumn{1}{c|}{$C_R$} & \multicolumn{1}{c|}{$C_G$} & \multicolumn{1}{c|}{$C_t$} & \multicolumn{1}{c|}{$C_R$} & \multicolumn{1}{c|}{$C_G$} & \multicolumn{1}{c|}{$C_t$} & \multicolumn{1}{c|}{$C_R$} \\ \hline
90,0 & 1,61 & 1,62 & 1,61 & 2,99 &  3,03 &  2,96 & 0,80 & 0,79 & 0,85 & 3,10 & 3,13 & 3,08 \\
95,0 & 2,19 & 2,20 & 2,18 & 5,00 &  5,06 &  4,93 & 1,18 & 1,37 & 1,48 & 5,14 & 5,24 & 5,14 \\
99,0 & 3,46 & 3,50 & 3,46 & 8,71 &  9,11 &  8,78 & 1,79 & 2,32 & 2,47 & 8,89 & 9,40 & 9,11 \\
99,5 & 4,04 & 4,21 & 4,09 & 4,15 &  5,82 &  4,64 & 4,22 & 6,10 & 5,69 & 5,91 & 8,42 & 7,33 \\
99,9 & 5,62 & 5,53 & 5,49 & 0,05 & -0,86 & -1,21 & 3,81 & 5,18 & 5,16 & 3,81 & 5,24 & 5,29 \\ \hline
\end{tabular}
\end{table}
\end{document}

Question. How to merge cells in the table correctlly?

My problem is \multirow{2}{*}{$\alpha$}

Best Answer

While your problem could be solved by loading multirow (you got an error message, didn't you?), there are also some smaller issues which are fixed in the following code: \emph in math mode is wrong and \mathit should be used.

I didn't fix the minus signs (you should) because I also present a better way to lay out the table that doesn't suffer from the problem.

\documentclass{article}
\usepackage{geometry}
\usepackage{multirow} % for your style
\usepackage{booktabs,siunitx} % for the better one

\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{table}[htp]
\centering
\caption{Caption for the jailed table}
\label{tab:boot-var}
\begin{tabular}{|c|r|r|r|r|r|r|r|r|r|r|r|r|} \hline
%
\multirow{2}{*}{$\alpha$} &
\multicolumn{3}{c|}{$\overline{\mathit{Va}R}_\alpha \times 10^{-2}$}&
  \multicolumn{3}{c|}{$\Delta \times 10^{-3}$} &
  \multicolumn{3}{c|}{$\mathit{SD} \times 10^{-2}$} &
  \multicolumn{3}{c|}{$\mathit{RMSE} \times 10^{-2}$} \\
\cline{2-13}
&
  \multicolumn{1}{c|}{$C_G$} &
  \multicolumn{1}{c|}{$C_t$} &
  \multicolumn{1}{c|}{$C_R$} &
  \multicolumn{1}{c|}{$C_G$} &
  \multicolumn{1}{c|}{$C_t$} &
  \multicolumn{1}{c|}{$C_R$} &
  \multicolumn{1}{c|}{$C_G$} &
  \multicolumn{1}{c|}{$C_t$} &
  \multicolumn{1}{c|}{$C_R$} &
  \multicolumn{1}{c|}{$C_G$} &
  \multicolumn{1}{c|}{$C_t$} &
  \multicolumn{1}{c|}{$C_R$} \\
\hline
90,0 & 1,61 & 1,62 & 1,61 & 2,99 &  3,03 &  2,96 & 0,80 & 0,79 & 0,85 & 3,10 & 3,13 & 3,08 \\
95,0 & 2,19 & 2,20 & 2,18 & 5,00 &  5,06 &  4,93 & 1,18 & 1,37 & 1,48 & 5,14 & 5,24 & 5,14 \\
99,0 & 3,46 & 3,50 & 3,46 & 8,71 &  9,11 &  8,78 & 1,79 & 2,32 & 2,47 & 8,89 & 9,40 & 9,11 \\
99,5 & 4,04 & 4,21 & 4,09 & 4,15 &  5,82 &  4,64 & 4,22 & 6,10 & 5,69 & 5,91 & 8,42 & 7,33 \\
99,9 & 5,62 & 5,53 & 5,49 & 0,05 & -0,86 & -1,21 & 3,81 & 5,18 & 5,16 & 3,81 & 5,24 & 5,29 \\ \hline
\end{tabular}
\end{table}

\begin{table}[htp]
\centering
\caption{Caption for the nice table}
\label{tab:boot-var+}
\begin{tabular}{
 @{}
 S[table-format=2.1]
 *{4}{S[table-format=1.2]}
 *{2}{S[table-format=-1.2]}
 *{6}{S[table-format=1.2]}
 @{}
}
\toprule
{$\alpha$} &
  \multicolumn{3}{c}{$\overline{\mathit{Va}R}_\alpha \times 10^{-2}$} &
  \multicolumn{3}{c}{$\Delta \times 10^{-3}$} &
  \multicolumn{3}{c}{$\mathit{SD} \times 10^{-2}$} &
  \multicolumn{3}{c}{$\mathit{RMSE} \times 10^{-2}$} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10} \cmidrule(l){11-13}
&
  {$C_G$} & {$C_t$} & {$C_R$} &
  {$C_G$} & {$C_t$} & {$C_R$} &
  {$C_G$} & {$C_t$} & {$C_R$} &
  {$C_G$} & {$C_t$} & {$C_R$} \\
\midrule
90,0 & 1,61 & 1,62 & 1,61 & 2,99 &  3,03 &  2,96 & 0,80 & 0,79 & 0,85 & 3,10 & 3,13 & 3,08 \\
95,0 & 2,19 & 2,20 & 2,18 & 5,00 &  5,06 &  4,93 & 1,18 & 1,37 & 1,48 & 5,14 & 5,24 & 5,14 \\
99,0 & 3,46 & 3,50 & 3,46 & 8,71 &  9,11 &  8,78 & 1,79 & 2,32 & 2,47 & 8,89 & 9,40 & 9,11 \\
99,5 & 4,04 & 4,21 & 4,09 & 4,15 &  5,82 &  4,64 & 4,22 & 6,10 & 5,69 & 5,91 & 8,42 & 7,33 \\
99,9 & 5,62 & 5,53 & 5,49 & 0,05 & -0,86 & -1,21 & 3,81 & 5,18 & 5,16 & 3,81 & 5,24 & 5,29 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

As you see, the input is much easier and the table has a more professional look.

enter image description here

Don't jail table cells, says the duck.

Related Question