2
\begin{tabular}{|c|c|c|c|c|}
\hline
 & \multicolumn{2}{c|}{Demand} &  \multicolumn{1}{|c|}{} &  \multicolumn{1}{c|}{}  \\  \cline{2-3}
 AAA& Group 1 & Group 2 &BBB & CCC \\ \cline{2-3}
\hline
 &   &  & &\\
\hline 
& &  & &\\
\hline
\end{tabular}

This is probably a simple exercise but the problem I have here is I cannot vertically center AAA BBB and CCC within their box. I would really appreciate some help.

1
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Commented Nov 23, 2014 at 19:58

1 Answer 1

2

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):

enter image description here

\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).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .