合并表格末尾最左边的两列

合并表格末尾最左边的两列

这里有一位沮丧的\LaTeX用户。我想合并表格的末尾,以便“地形校正不确定性”与“编号”列下方的单元格合并。

错误的表格,我想将“地形校正不确定性”单元格与“1”下方的单元格合并

我想要的是:

我想用桌子做什么

我所做的是这样的:

\begin{table} [!htb]
    \caption{Summary of uncertainties in the AVF Bouguer anomaly data}
    \medskip
    \centering
    \begin{tabular}{| m{23pt} | m{180pt}| m{180pt} |}
        \hline
        \rowcolor{black!30}
        \rule[-1ex]{0pt}{2.5ex} \Centering \bfseries No.
        & \Centering \bfseries Source of Uncertainty & \Centering \bfseries Estimated Uncertainty (mGal)\\
        \hline
        \rule[-1ex]{0pt}{2.5ex}
        \Centering 1 & \makecell[l]{ Latitude correction \\ (horizontal positioning)} &\Centering $\pm0.05$ mGal \\
        \hline
        \rule[-1ex]{0pt}{2.5ex}
        \multicolumn{2}{c}{Terrain correction uncertainty} &\Centering $\pm0.03$ mGal \\
        \hline
    \end{tabular}
    \label{Tab:AVFUncertTable}
\end{table}

最后\multicolumn给出“放错位置\omit. ...umn{2}{c}{Terrain correction uncertainty}”错误。我在 StackExchange 中读到的所有示例都提供了页眉合并。我需要页脚合并。

请帮忙。

答案1

您的问题已由@Bernard 评论解决,但在编写表格时使用该tabularray包会非常方便:

\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{xcolor}
\usepackage{tabularray}

\usepackage{siunitx}

\begin{document}
\begin{table} [!htb]
    \caption{Summary of uncertainties in the AVF Bouguer anomaly data}
    \label{Tab:AVFUncertTable}
\centering
    \begin{tblr}{hlines, vlines,
                 colspec = {c X[l,m] X[c,m] },
                 rowsep=5pt,
                 row{1} = {font=\bfseries, bg=gray!50}
                }
No. & \SetCell[c=1]{c} Source of Uncertainty 
            & \SetCell[c=1]{c} Estimated Uncertainty (mGal) \\
1   & {Latitude correction \\ (horizontal positioning)} 
            & \qty{\pm0.05}{mGal}       \\
\SetCell[c=2]{r}    Terrain correction uncertainty
    &       & \qty{\pm0.03}{mGal}       \\
    \end{tblr}
\end{table}
\end{document}

在此处输入图片描述

写表的语法tabularray与标准表不同。有关详细信息,请参阅包文档。

  • \SetCell[c=2]{r}相当于\multicolumn{2}{r} ...标准表中的命令

  • \row{1} = {font=\bfseries, bg=gray!50}定义第一行的字体和背景颜色

答案2

在此处输入图片描述

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage[table]{xcolor}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}

\begin{document}
    \begin{table} [!htb]
        \caption{Summary of uncertainties in the AVF Bouguer anomaly data}
        \medskip
        \centering
        \begin{tabular}{m{23pt} m{180pt} m{180pt}}

            \rowcolor{black!30}

            \thead{No.}
                &  \thead{Source of Uncertainty} 
                    & \thead{Estimated Uncertainty (mGal)}\\    

            1 & \makecell[l]{ Latitude correction \\ (horizontal positioning)} & $\pm0.05$ mGal \\
            \hline

            \multicolumn{2}{r}{Terrain correction uncertainty} &$\pm0.03$ mGal \\
            \hline
        \end{tabular}
        \label{Tab:AVFUncertTable}
    \end{table}
\end{document}

答案3

具有({NiceTabular}具有nicematrix优势:规则惯于在某些 PDF 阅读器的某些缩放级别下,它们似乎会消失在灰色单元格附近)。

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table} [!htb]
\caption{Summary of uncertainties in the AVF Bouguer anomaly data}
\medskip
\centering
\begin{NiceTabular}{wc{23pt}m{180pt}wc{180pt}}%
  [hvlines,colortbl-like,cell-space-limits=3pt]
\rowcolor{black!30}
\bfseries No. & \centering \bfseries Source of Uncertainty &  \bfseries Estimated Uncertainty (mGal)\\
1 & \Block[l]{}{ Latitude correction \\ (horizontal positioning)} & $\pm0.05$ mGal \\
\Block[r]{1-2}{Terrain correction uncertainty} & & $\pm0.03$ mGal \\
\end{NiceTabular}
\label{Tab:AVFUncertTable}
\end{table}

\end{document}

您需要多次编译(因为nicematrix使用 PGF/Tikz 节点)。

上述代码的输出

相关内容