I am trying to center vertically the text in table cells but I can't make it work with my current table. This is the setup I have so far using the m
argument, which I attempted by looking here.
\documentclass[10pt,a4paper]{article}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} % use color
\usepackage{booktabs} % commands for table rules
\usepackage{tabularx}
\usepackage{lipsum}
\newcommand{\scell}[1]{\cellcolor{black!25} \bfseries #1 }
\newcommand{\slcell}[1]{\cellcolor{black!25} #1 }
\begin{document}
\begin{tabular}{|>{\arraybackslash}m{1.8cm}|>{\centering\arraybackslash}m{3.5cm}|>{\centering\arraybackslash}m{2.8cm}|>{\centering\arraybackslash}m{2.8cm}|>{\centering\arraybackslash}m{2.8cm}|}
\hline
& \textbf{Given names} & \multicolumn{3}{c|}{\textbf{\centering Testing}} \tabularnewline
\hline
\multicolumn{5}{|l|}{ \scell{Category 1}} \tabularnewline
\hline
& Person 1 & \multicolumn{3}{p{9cm}|}{\lipsum[1] } \tabularnewline
\hline
\end{tabular}
\end{document}
This gives me the following result:
Best Answer
Use
\multicolumn3{m{9cm}}{…}
instead ofp{9cm}
. As your table is too wide to fit the margins, I took the opportunity to change it usingtabularx
. Also note theusenames
option forxcolor
is obsolete: it's the default now.