我想将每个单元格中的文本水平和垂直居中。使用下面的代码,文本水平居中,而不是垂直居中,并显示在单元格的顶部。提前感谢!
\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}

发布于 2020-08-29 06:24:41
请,请,请看看如何创建漂亮的表格,例如user manual of the booktabs package。把你的数据放进数据监狱是不好的。做斑马线餐桌更糟糕。同时做这两件事是很可怕的。
\documentclass[jou]{apa7}
\usepackage{tabularx,colortbl}
\begin{document}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
{
\setlength{\extrarowheight}{30pt}
\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 \\[30pt] \hline
\end{tabular}
}
\end{document}

https://stackoverflow.com/questions/63640135
复制相似问题