In a Latex Table, how can I automatically resize cell heights to account for superscripts?
The cellspace
package is here for that! You can define minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S
(or C
if you load siunitx
, as this package already defines an S
column type). Demo:
\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}
alternatively, with makecell
package :-)
\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}