You can either use the functionality of multirow
, or merely raise/lower the contents into place, making sure you also remove any vertical height as a result of the movement. Below, \vertcenter
does exactly that, moving the contents up by half of the regular baseline skip (.5\normalbaselineskip
):
\documentclass{article}
\usepackage{booktabs,multirow}
\newcommand{\vertcenter}[1]{\raisebox{#1}[0pt][0pt]}
\begin{document}
\begin{tabular}{ | *{5}{c|} }
\hline
& \multicolumn{2}{c|}{Demand} & \multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} \\
\cline{2-3}
\multirow{-2}{*}{AAA} & Group 1 & Group 2 & \vertcenter{.5\normalbaselineskip}{BBB} & \vertcenter{.5\normalbaselineskip}{CCC} \\
\hline
A & B & C & D & E \\
\hline
5 & 4 & 3 & 2 & 1 \\
\hline
\end{tabular}
\bigskip
\begin{tabular}{ *{5}{c} }
\toprule
& \multicolumn{2}{c}{Demand} \\
\cmidrule{2-3}
AAA & Group 1 & Group 2 & BBB & CCC \\
\midrule
A & B & C & D & E \\
5 & 4 & 3 & 2 & 1 \\
\bottomrule
\end{tabular}
\end{document}
I've also included a booktabs
version of the table, which removes most of the horizontal and vertical rules, in lieu of a more polished finish. As such, there's no real need for vertical re-adjustment of the headings (in my opinion).
\documentclass{...}
and ending with\end{document}
.