会议的提交指南如下 Word 表格所示:
到目前为止,我得到:
使用以下代码:
\usepackage{tabularx,booktabs}
\usepackage{array}
\begin{document}
\begin{table}[ht]
\renewcommand{\arraystretch}{1.25}
\centering
\label{tab:lme-mean}
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{3}{|c|}{\textbf{Table 1. A Sample Table}} \\
\hline
& Treatment 1 & Treatment 2 \\
\hline
Setting A & 125 & 95 \\
\hline
Setting B & 85 & 102 \\
\hline
Setting C & 98 & 85 \\
\hline
\end{tabular}
\caption{Test table with caption}
\end{table}
\end{document}
问题:如何为表格的第一行添加更多顶部和底部空间(即调整填充)?另外,稍微增加表格的宽度也是一个好处。
答案1
像这样?
使用包makecell
及其宏\thead{...}
:
\documentclass{article}
\usepackage{booktabs, makecell, tabularx,}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}[ht]
\renewcommand{\arraystretch}{1.2}
\centering
\label{tab:lme-mean}
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{3}{|c|}{\thead{Table 1. A Sample Table}} \\
\hline
& Treatment 1 & Treatment 2 \\
\hline
Setting A & 125 & 95 \\
\hline
Setting B & 85 & 102 \\
\hline
Setting C & 98 & 85 \\
\hline
\end{tabular}
\caption{Test table with caption}
\end{table}
\end{document}