表格邊框不完整、被截斷、不漏水

表格邊框不完整、被截斷、不漏水

以下(相對簡單)表格周圍的邊框不完整/被截斷。我缺少什麼才能讓這張桌子看起來更「無懈可擊」和專業?

\begin{tabular} {|p{3cm}|p{1.5cm}|} 
\toprule
\centering\textbf{Feature} & \centering\textbf{MRR}  \tabularnewline
\midrule
Heuristic only & 0.59    \tabularnewline\hline
Heuristic with QACES & 0.63   \tabularnewline\hline
Percentage change & +6.8\% \tabularnewline

\bottomrule
\end{tabular}

截斷的邊框:

答案1

請勿將垂直標尺與包的畫線宏一起使用booktabs。實際上,根本不要使用垂直規則——相信我,它們不會被錯過。

這是使用者指南第 2 部分的摘錄書本標籤包裹:

在此輸入影像描述


在此輸入影像描述

\documentclass{article}
\usepackage{booktabs,array,ragged2e}
\begin{document}

\begin{tabular} {@{} 
          >{\RaggedRight\hangafter1\hangindent1em}p{3cm} % automatic hanging indentation
          c 
          @{}} 
  \toprule
  \textbf{Feature}     & \textbf{MRR} \\
  \midrule
  Heuristic only       & 0.59    \\
  Heuristic with QACES & 0.63    \\
  Percentage change    & +6.8\%  \\
  \bottomrule
\end{tabular}

\end{document}

答案2

如果您確實想使用垂直規則 with booktabs(這根本不符合 的精神booktabs),您可以{NiceTabular}使用nicematrix

\documentclass{article}
\usepackage{nicematrix}
\usepackage{booktabs}

\begin{document}

\begin{NiceTabular} {|p{3cm}|p{1.5cm}|} 
\toprule
\centering\textbf{Feature} & \centering \textbf{MRR} \tabularnewline
\midrule
Heuristic only & 0.59   \\
Heuristic with QACES & 0.63  \\
Percentage change & +6.8\% \\
\bottomrule
\end{NiceTabular}

\end{document}

上述程式碼的輸出

答案3

謝謝@samcarter-is-at-topanswers-xyz

你讓我朝著正確的方向前進,但我無法在不破壞文件中「其他」表格的情況下刪除 booktabs 套件。

我刪除了 toprule/midrule/bottomrule (booktabs 套件的一部分)並用簡單的 hline 替換它們:-

\begin{tabular}{|c|c|}
\hline
\centering\textbf{Feature} & \centering\textbf{MRR}  \tabularnewline
\hline
Heuristic only & 0.57 $\pm$ 0.12    \\
Heuristic with QACES & 0.60 $\pm$ 0.12  \\
Percentage change & +5.3\% \\
\hline
\end{tabular}

這會產生:- 不含書籤的防水桌子

答案4

我還主張取消垂直規則。只因為精心設計的桌子可以說話本身沒有任何不必要的添加。

不過,有一種方法可以合併如果加載,則具有不同粗細的水平線甚至垂直線大批包裹。您只需將|和分別更改\hline為自定義定義 sa!{...}\noalign{...}(更多信息這裡.)

這個例子:

\documentclass{article}
\usepackage{array}

\begin{document}
\begin{table}[tbh]
    \setlength\arrayrulewidth{0.2pt}
    \renewcommand*\arraystretch{1.35}
    \begin{tabular}{|
            >{\raggedright}p{3cm} !{\vrule width 0.8pt}
            >{\centering\arraybackslash}p{1.5cm} |
        } 
        \noalign{\hrule height 0.8pt}
        \centering\textbf{Feature} & \textbf{MRR} \\\noalign{\hrule height 0.5pt}
        Heuristic only             & 0.59         \\\hline
        Heuristic with QACES       & 0.63         \\\hline
        Percentage change          & +6.8\%       \\\noalign{\hrule height 0.8pt}
    \end{tabular}
    \end{table}
\end{document}

在此輸入影像描述

相關內容