我想将一列中的垂直文本居中放置在其他单元格中。我的示例是:
\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{tabular}{lcc}
\toprule
&Description & Description \\ \midrule
\multirow{7}{*}{\rotatebox[origin=c]{90}{Test sideways}} & test & 1.0 \\[1.5ex]
& test & 1.0 \\[1.5ex]
& test & 1.0 \\[1.5ex]
& test & 1.0 \\[1.5ex]
& test & 1.0\\[1.5ex]
& test & 1.0 \\[1.5ex]
& test & 1.0 \\ \bottomrule
\end{tabular}
\end{document}
运行此程序得到下表:
“Test sideways” 与其他单元格(显示 test 和 1.0)不对齐。有没有办法让垂直文本居中于其他单元格?
答案1
欢迎来到 TeX.SE!
使用tabularray
、rotating
和makecell
包并不难:
\documentclass{article}
\usepackage{rotating} % needed
\usepackage{makecell} % needed
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{table}[ht]
\centering
\settowidth\rotheadsize{ Test sideways }
\begin{tblr}{colspec={ccc},
cell{2-Z}{1} = {cmd=\rotcell[cc]},}
\toprule
& Description & Description \\
\midrule
\SetCell[r=7]{c} Test sideways
& test & 1.0 \\
& test & 1.0 \\
& test & 1.0 \\
& test & 1.0 \\
& test & 1.0 \\
& test & 1.0 \\
& test & 1.0 \\
\bottomrule
\end{tblr}
\end{table}
\end{document}