You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX tabular表格:如何实现单元格跨多列的合并排版

表格跨列排版实现方案

LaTeX 原生 tabular 环境自带单元格跨列支持,无需额外加载宏包,直接使用核心命令 \multicolumn 即可实现需求。

  • 命令基础语法:
    \multicolumn{<跨列数>}{<单元格边框/对齐格式>}{<单元格内容>}
  • 格式参数需要和表格原有竖线规则匹配,避免边框错位。你的表格列定义为 {|l||c|c|c|},合并后三列(Male、Female、Any)时,第一列与后续列之间的双竖线已由第一列的格式定义完成,合并区域只需设置居中对齐、保留表格最右侧边框,格式写为 c| 即可。

具体代码修改

将原有三行仅在单格填值的零散写法,替换为三列合并的统一写法:

  • 原零散写法:Tritanomaly* && 0.02\% & \\
  • 修改为跨列写法:Tritanomaly* & \multicolumn{3}{c|}{0.02\%} \\\hline
  • Tritanopia、Monochromacy 两行按同样规则替换对应数值即可。

完整可运行代码

\usepackage{slashbox}
\usepackage[table]{xcolor}

\begin{document}

\begin{table}[h]
\centering
{\rowcolors{2}{gray!15}{gray!0}
\begin{tabular}{|l||c|c|c|}
\hline
\backslashbox{CVD}{Sex}
&Male&Female&\textbf{Any}\\\hline\hline
Deuteranomaly & 5\% & 0.35\% & 2.68\% \\\hline
Deuteranopia & 1\% & 0.1\% & 0.56\% \\\hline
Protanomaly & 1.08\% & 0.03\% & 0.55\% \\\hline
Protanopia & 1.01\% & 0.01\% & 0.51\% \\\hline
Tritanomaly* & \multicolumn{3}{c|}{0.02\%} \\\hline
Tritanopia* & \multicolumn{3}{c|}{0.01\%} \\\hline
Monochromacy* & \multicolumn{3}{c|}{0.0001\%} \\\hline
\textbf{Total} & \textbf{8.12}\% & \textbf{0.52}\% & \textbf{4.32}\% \\\hline
\end{tabular}
\end{table}

\end{document}

适配说明

  • 使用 \rowcolors 设置行交替底色时,\multicolumn 合并的单元格会自动继承当前行的底色规则,无需额外调整。
  • 若后续需要跨多行排版、更复杂的边框控制,可按需引入 multirow、tabularray 等宏包,当前需求用原生命令即可完全覆盖。

内容的提问来源于stack exchange,提问作者Heavenly Journey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.28 07:45:03