如何在表格中添加垂直线?

如何在表格中添加垂直线?

我想在表格中添加垂直线。有人能建议我修改以下代码以在表格中添加正确的垂直线吗?示例代码粘贴在下面。输出的屏幕截图已附上。非常感谢。

 \documentclass[sigconf, authordraft]{acmart}

\usepackage{booktabs}
\usepackage{multirow}
%
\begin{document}
\begin{table*}[!h]
\centering
\caption{Summary of Quantitative Evaluation}                                    
\label{tab:table3}
\begin{tabular}{|p{0.5 cm}|p{0.85 cm}|p{12 cm}|}
%\begin{tabular}{ccc}
\toprule
Sl.No. & Metric & Remark   \\
\midrule
1 & Rel Bias & Smaller relative bias (almost equal to 0) is obtained for all fused bands and for all 7 fusion methods.\\    
\bottomrule
2 & Rel Bias & Smaller relative bias (almost equal to 0) is obtained for all fused bands and for all 7 fusion methods.
\\
 \bottomrule
3& Rel Bias & Smaller relative bias (almost equal to 0) is obtained for all fused bands and for all 7 fusion methods. \\
 \bottomrule
 \end{tabular}
\end{table*}

\end{document} 

答案1

要获得与 booktabs 相交的垂直线和水平线,您必须抑制 booktabs 规则的填充。您可以用最小在列中每个单元格的顶部和底部填充带有字母前缀的说明符S,加载cellspace包。以下是可能的代码:

 \documentclass{article}
\usepackage{booktabs}
\usepackage{multirow, tabularx, caption, cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}
\addparagraphcolumntypes{X}
%
\begin{document}

\begin{table*}[!h]
\centering
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\setlength{\tabcolsep}{4pt}
\caption{Summary of Quantitative Evaluation}
\label{tab:table3}
\begin{tabularx}{\linewidth}{|l|l|S{X}|}
\toprule
Sl.No. & Metric & Remark \\
\midrule
1 & Rel Bias & Smaller relative bias (almost equal to 0) is obtained for all fused bands and for all 7 fusion methods.\\
\bottomrule
2 & Rel Bias & Smaller relative bias (almost equal to 0) is obtained for all fused bands and for all 7 fusion methods.
\\
 \bottomrule
3& Rel Bias & Smaller relative bias (almost equal to 0) is obtained for all fused bands and for all 7 fusion methods. \\
 \bottomrule
\end{tabularx}
 \end{table*}

\end{document} 

在此处输入图片描述

注 1:如果加载siunitx定义S列类型的,则必须使用另一个前缀;默认值为C

笔记2:除了 booktabs 之外,一些包还定义了具有可变厚度的水平线:(boldline没有填充,但也定义了可变宽度的垂直线)和makecell(还允许您为表格的所有单元格定义固定填充)。

相关内容