使用 \makecell,我希望每行的第一列居中(cc),但其余列位于左上角(tl)。这可能吗?
\documentclass{article}
\usepackage{array}
\usepackage{makecell}
\newcolumntype{R}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcommmand\tab{\hspace{10mm}}
\begin{document}
\begin{table}[]
\centering
\begin{tabular}{|R{1in}|R{1in}|R{1in}|R{1in}|}
Test Header & Test Header & Test Header & Test Header \\
\hline
\makecell[cc]{Row 1}
& \makecell[tl]{Item 1 \\ \tab Value}
& \makecell[tl]{Item 2 \\ \tab Value \\ Item 3 \\ \tab Value}
& \makecell[tl]{Item 4 \\ \tab Value \\ Item 5 \\ \tab Value \\ Item 6 \\ \tab Value} \\
\hline
\makecell[cc]{Row 2}
& \makecell[tl]{Item 1 \\ \tab Value}
& \makecell[tl]{Item 2 \\ \tab Value \\ Item 3 \\ \tab Value}
& \makecell[tl]{Item 4 \\ \tab Value \\ Item 5 \\ \tab Value \\ Item 6 \\ \tab Value} \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
tblr
使用包提供的环境非常容易tabularray
。
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}
\centering
\begin{tblr}{
hlines,
%vlines, % uncomment if you really want vertical lines
columns={1in, l, h}, % default left and head alignment
column{1}={c, m}, % column1 horizontal and vertical centered
}
Test Header & Test Header & Test Header & Test Header \\
Row 1
& {Item \\ Value}
& {Item 2 \\ Value \\ Item 3 \\ Value}
& {Item 4 \\ Value \\ Item 5 \\ Value \\ Item 6 \\ Value} \\
Row 2
& {Item 1 \\ Value}
& {Item 2 \\ Value \\ Item 3 \\ Value}
& {Item 4 \\ Value \\ Item 5 \\ Value \\ Item 6 \\ Value} \\
\end{tblr}
\end{table}
\end{document}
在tblr
环境中,您可以像往常一样用 括起条目{}
并用于换行。\\