Reputation: 359
I would like to center the text in each cell horizontally and vertically. With the code below, the text is centered horizontally but not vertically and appears at the top of the cells. Thanks in advance!
\documentclass[jou]{apa7}
\usepackage{tabularx,colortbl}
\begin{document}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\begin{tabular}{| L{1cm} | C{5cm} | C{5cm} | C{5cm} |} \hline
\rowcolor[gray]{.4}& \color{white}Cell 1 & \color{white}Cell 2 & \color{white}Cell 3 \\[30pt] \hline
\cellcolor[gray]{.4}\color{white}Cell 4 & Cell 5 & Cell 6 & Cell 7 \\[100pt] \hline
\end{tabular}
\end{document}
Upvotes: 5
Views: 26138
Reputation: 38942
Please, please, please, have a look at how to create nice looking tables, e.g. the user manual of the booktabs
package. Putting your data into a data prison is bad. Making a zebra strip table is worse. Doing both at the same time is just horrible.
\documentclass[jou]{apa7}
\author{author names}
\shorttitle{subtitle}
\title{title}
\usepackage{tabularray}
\begin{document}
\noindent%
\begin{tblr}{
hlines,
vlines,
row{1} = {bg=gray,fg=white},
rows = {ht=2cm},
columns = {halign=c},
colspec = {Q[1cm,bg=gray,fg=white] XXX},
}
& Cell 1 & Cell 2 & Cell 3 \\
Cell 4 & Cell 5 & Cell 6 & Cell 7 \\
\end{tblr}
\end{document}
Upvotes: 2