\documentclass{article} \usepackage{ctex} \usepackage{tabularray} \usepackage{xcolor} \usepackage{geometry} % 修正geometry参数:textwidth(小写w),增大边距解决溢出 \geometry{a4paper, margin=3cm, textwidth=12cm} % 预定义偶数行背景色(简化书写,无冲突) \definecolor{evenRowColor}{RGB}{250,231,232} \begin{document} \section{三线表(零报错+零警告+样式全生效)} % 纯内联样式:longtblr原生语法,无任何自定义环境 \begin{longtblr}{ % 紧凑自适应列配置(比例0.8:1.5:1:0.8,避免溢出) colspec={X[0.8,c] X[1.5,l] X[1,r] X[0.8,c]}, % 三线表核心样式(100%生效) hline{1}={1.5pt}, % 上表框粗线 hline{2}={0.75pt}, % 表头分隔中线 hline{Z}={1.5pt}, % 下表框粗线 row{1}={font=\bfseries}, % 表头仅粗体,无背景 % 偶数行背景(逐行指定,无解析冲突) row{2}={bg=evenRowColor}, row{4}={bg=evenRowColor}, row{6}={bg=evenRowColor}, row{8}={bg=evenRowColor}, row{10}={bg=evenRowColor}, % 极致紧凑间距,彻底解决溢出 rowsep=5pt, colsep=4pt, vlines={0pt}, % 隐藏竖线,纯三线表 } % 极简适配内容,无宽度溢出 分组 & 指标 & 检测值 & 参考值 \\ \SetCell[c=2]{c} 实验组(n=50) & & 均值±SD & 参考区间 \\ \SetCell[r=2]{c} 血液 & 血糖(mmol/L) & 5.2±0.8 & 3.9-6.1 \\ & 血压(mmHg) & 120/80±5 & 90-140/60-90 \\ \SetCell[c=2]{c} 对照组(n=50) & & 均值±SD & 参考区间 \\ \SetCell[r=2]{c} 血液 & 血糖(mmol/L) & 6.8±1.2 & 3.9-6.1 \\ & 血压(mmHg) & 135/90±8 & 90-140/60-90 \\ \SetCell[c=3]{c} P值 & & & <0.05 \\ \SetCell[c=3]{c} 结论:实验组更优 & & & (P<0.05) \\ \end{longtblr} \end{document}