该表来自 SAS 输出。\newline 无法正常工作。例如,“尾部修剪百分比”应为
尾部修剪百分比
但它显示为
尾部修剪百分比
这是一个最小的例子
\documentclass{article}
\usepackage{natbib}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{longtable}
\usepackage{array}
\usepackage{listings}
\usepackage{multicol}
\usepackage{url}
\lstloadlanguages{SAS} \lstset{language = SAS}
\begin{document}
\begin{longtable}{|r|r|r|r|r|r|r|r|r|}\hline
\multicolumn{9}{|c|}{Trimmed Means}\\\hline
Percent {\newline} Trimmed \newline in Tail & Number \newline Trimmed \newline in Tail & Trimmed \newline Mean & Std Error \newline Trimmed \newline Mean & \multicolumn{2}{|c|}{95\%~Confidence~Limits} & DF & t for H0: \newline Mu0=0.00 & Pr~>~|t|\\\hline
\endhead
10.27 & 27 & 463.8867 & 25.08152 & 414.4401 & 513.3332 & 208 & 18.49516 & <.0001\\\hline
\end{longtable}
\end{document}
答案1
现在,您可以使用新的 LaTeX3 包编写多行单元格,而无需固定列宽tabularray
:
\documentclass{article}
\usepackage[a4paper,left=2cm,right=2cm]{geometry}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[
caption = {Long Caption},
label = {tblr:test},
]{
colspec={|r|r|r|r|r|r|r|r|r|}, rowhead = 2, row{2}={m},
cell{1}{1} = {c=9}{c}, cell{2}{5} = {c=2}{c},
}
\hline
Trimmed Means \\
\hline
{Percent \\ Trimmed \\ in Tail} & {Number \\ Trimmed \\ in Tail} & {Trimmed \\ Mean} &
{Std Error \\ Trimmed \\ Mean} & {$95\%$ \\ Confidence Limits} & & DF &
{$t$ for $H_0$: \\ $\mu_0=0.00$} & $\mathrm{Pr}>|t|$ \\
\hline
$10.27$ & $27$ & $463.8867$ & $25.08152$ & $414.4401$ & $513.3332$ & $208$ & $18.49516$ & $<.0001$ \\
\hline
\end{longtblr}
\end{document}