我使用包H
中的命令创建了下表float
。下面的主要问题是指数太靠近单元格顶部。有没有办法自动增加单元格高度?感谢您的任何建议。
\usepackage(float)
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|}
\hline
& Compute on $X^A$ & Compute on $(X^A, X^B)$ \\
\hline
Estimate on $X^A$ & Correct & Incorrect \\
Estimate on $(X^A, X^B)$ & Correct & Incorrect \\
\hline
\end{tabular}
\end{table}
答案1
或者,使用makecell
包 :-)
\documentclass{article}
\usepackage{makecell}
\setcellgapes{4pt}
\begin{document}
\begin{table}[htb]
\centering
\makegapedcells
\begin{tabular}{|c|c|c|}
\hline
& Compute on $X^A$ & Compute on $(X^A, X^B)$ \\
\hline
Estimate on $X^A$
& Correct & Incorrect \\
Estimate on $(X^A, X^B)$
& Correct & Incorrect \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
这cellspace
这里有这个包!你可以最小在以字母为前缀的说明符的列中单元格顶部和底部的垂直间距S
(或者C
如果您加载siunitx
,因为此包已经定义了S
列类型)。演示:
\documentclass{article}
%\usepackage{array}
\usepackage{float}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{3pt}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|Sc|Sc|Sc|}
\hline
& Compute on $X^A$ & Compute on $(X^A, X^B)$ \\
\hline
Estimate on $X^A$ & Correct & Incorrect \\
Estimate on $(X^A, X^B)$ & Correct & Incorrect \\
\hline
\end{tabular}
\end{table}
\end{document}
答案3
或者,您可以使用大批以及命令\arraystretch
和\extrarowheight
,在这里给出了完美的结果:
\documentclass{article}
\usepackage{float, array}
\begin{document}
\begin{table}[H]
\renewcommand{\arraystretch}{1.3}
\setlength{\extrarowheight}{1pt}
\centering
\begin{tabular}{|c|c|c|}
\hline
& Compute on $X^A$ & Compute on $(X^A, X^B)$ \\
\hline
Estimate on $X^A$ & Correct & Incorrect \\
Estimate on $(X^A, X^B)$ & Correct & Incorrect \\
\hline
\end{tabular}
\end{table}
\end{document}