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

如何修改LaTeX表格最后一行,将多列合并为单列展示统计数据

问题描述

现有如下LaTeX表格代码:

\begin{table}[h!]
\caption{Top 5 letras menos frequentes retornadas pelo método \emph{Lossy Counter} quando se considera $e$ como $0.1, 0.01, 0.001$, Lossy($e$), comparando com as letras menos frequentes retornadas pelo método \emph{Exact Counter} - \textit{O Livro de Cesário Verde}}
\label{e_lossy}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{| *{9}{c|}}
\hline
 \backslashbox{Top 5}{Counter} & \multicolumn{2}{c|}{Exact} & \multicolumn{2}{c|}{Lossy (0.1)} & \multicolumn{2}{c|}{Lossy (0.01)} & \multicolumn{2}{c|}{Lossy (0.001)}\ \hline
 1 & K & 4 & V & 340 & Y & 1 & Y & 47  \\ \hline
 2 & Y & 54 & P & 1426 & X & 72 & X & 155 \\
\hline
 3 & X & 155 & L & 2091 & J & 102 & J & 208 \\ \hline
 4 & J & 28 & C & 2527 & Z & 325 & Z & 344 \\ \hline
 5 & Z & 344 & T & 2833 & F & 701 & F & 701 \\ \hline
 Nº Letras & 25 &  & 15 & . & 24 & . & 24 & . \\ \hline
\end{tabular}%
}
\end{table}

当前表格最后一行“Nº Letras”的显示效果为:

NºLetras | 25 | .| 15 | . | 24 | . | 24 | . |

需要将该行修改为如下形式:

NºLetras | 25 | 15 | 24 | 24 |

其中25对应Exact列的整体统计值,15对应Lossy(0.1)列,24对应Lossy(0.01)列,24对应Lossy(0.001)列,即每个Counter对应的原两列合并为一列展示统计数值。

修改后的LaTeX代码

要实现需求效果,只需在最后一行用\multicolumn合并对应列,具体代码如下:

\begin{table}[h!]
\caption{Top 5 letras menos frequentes retornadas pelo método \emph{Lossy Counter} quando se considera $e$ como $0.1, 0.01, 0.001$, Lossy($e$), comparando com as letras menos frequentes retornadas pelo método \emph{Exact Counter} - \textit{O Livro de Cesário Verde}}
\label{e_lossy}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{| *{9}{c|}}
\hline
 \backslashbox{Top 5}{Counter} & \multicolumn{2}{c|}{Exact} & \multicolumn{2}{c|}{Lossy (0.1)} & \multicolumn{2}{c|}{Lossy (0.01)} & \multicolumn{2}{c|}{Lossy (0.001)}\ \hline
 1 & K & 4 & V & 340 & Y & 1 & Y & 47  \\ \hline
 2 & Y & 54 & P & 1426 & X & 72 & X & 155 \\
\hline
 3 & X & 155 & L & 2091 & J & 102 & J & 208 \\ \hline
 4 & J & 28 & C & 2527 & Z & 325 & Z & 344 \\ \hline
 5 & Z & 344 & T & 2833 & F & 701 & F & 701 \\ \hline
 Nº Letras & \multicolumn{2}{c|}{25} & \multicolumn{2}{c|}{15} & \multicolumn{2}{c|}{24} & \multicolumn{2}{c|}{24} \\ \hline
\end{tabular}%
}
\end{table}

说明

  • \multicolumn{2}{c|}{数值}用于合并每个Counter对应的两列,其中2代表合并列数,c|保证单元格居中对齐且保留右侧竖线,维持表格边框一致性。
  • 移除了原行中多余的占位符(空格和.),直接将统计值放入合并后的单元格。

内容的提问来源于stack exchange,提问作者Goncalo Freitas

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 11:00:55