我尝试在表格的多列命令中使用换行命令。当我使用它时,表格会以以下方式混乱。我该如何修复这个问题?
\begin{tabular}{l|*{8}{c}r}
&\multicolumn{2}{c}{Aug. D-F Z(t)-stat} & \multicolumn{2{c}{P-P Z(t)-stat.}\\
\hline
Team & Un-Differenced & Differenced & Un-Differenced & Differenced \\
\hline
K-12 Education & 2 & 4 & 2 & 4 \\
Medicaid and Welfare & 6 & 3 & 2 & 4 \\
Public Health and Hospitals & 6 & 2 & 2 & 4 \\
Natural Resources & 6 & 2 & 2 & 4 \\
Higher Education & 6 & 4 & 2 & 4 \\
Highways & 6 & 4 & 2 & 4 \\
Police and Prisons & 6 & 4 & 2 & 4 \\
Other Spending & 6 & 4 & 2 & 4 \\
\hline
\multicolumn{8}{c}{Note: Augmented Dickey Fuller Z(t) test statistics word word wword wword word word word \\word word.}
\end{tabular}
答案1
像这样?
由包talltblr
定义tabularray
:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{talltblr}[
caption = {Overview of statistic. Diff.: Differened},
remark{Note} = {Augmented Dickey Fuller Z(t) test statistics word word word word word word word word word.}
]{colspec = {l| *{4}{c}}}
& \SetCell[c=2]{c} Aug. D-F Z(t)-stat
& & \SetCell[c=2]{c} P-P Z(t)-stat.
& \\
\hline
Team & Un-Diff. & Diff. & Un-Diff. & Diff. \\
\hline
K-12 Education & 2 & 4 & 2 & 4 \\
Medicaid and Welfare & 6 & 3 & 2 & 4 \\
Public Health and Hospitals & 6 & 2 & 2 & 4 \\
Natural Resources & 6 & 2 & 2 & 4 \\
Higher Education & 6 & 4 & 2 & 4 \\
Highways & 6 & 4 & 2 & 4 \\
Police and Prisons & 6 & 4 & 2 & 4 \\
Other Spending & 6 & 4 & 2 & 4 \\
\hline
\end{talltblr}
\end{document}
- 在列类型中
c
(或l
,t
),单元格中的文本只能在一行中,多行文本只能在p{width}
(或b
或m
)列类型中写入。这意味着在您的例子中,您应该知道表格宽度。 - 通过使用
threeparttable
或包talltblr
中定义的等效项tabullarray
,可以通过使用表格注释或备注 ia 简单地解决这个问题,ia 用于上面的 MWE, - 不清楚为什么只使用五列却要指定十列。