[Tex/LaTex] \Huge Text in Tabular touches table border

fontsizetables

If I want different font sizes within a table, how do I prevent the text from touching table borders? And why is it touching the table border in the first place?

\documentclass{article}

\pagestyle{empty}

\newcommand{\mycoordinates}
{
\vspace{0.2cm}
\begin{tabular}{|c|l|} \hline
\Huge Point & \Huge Original \(\rightarrow\) Transformed \\ \hline 
\Huge A & \\ \hline
B & \\ \hline
C & \\ \hline
\end{tabular}
}

\begin{document}

\mycoordinates

\end{document}

enter image description here

Best Answer

LaTeX tables are generally very tight. You can play with \arraystretch but in this case (different font sizes for different rows) it may not be very easy.

Two packages can tackle this problem, each with its own limitations:

  • cellspace defines minimal distances between cell contents and the row above or the row below. All you have to do is define these minimal distances, and prefix the relevant columns specifiers with the letter S (or C if you use siunitx).
  • makecell can add vertical spacing at the top and bottom of cells. You have to set this spacing, then use the command \makegapedcells.

Another solution is to give up all vertical rules, to have a more professional looking table, and replace \hline\s and\clines with the\toprule, \midrule, \cmidrule and \bottomrule commands from booktabs, which introduces somme vertical padding around these rules.

Here are examples of these solutions. You'll find more details in the documentations of the packages:

\documentclass{article}
\usepackage{cellspace} 
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\usepackage{makecell} 
\setcellgapes{5pt}
\usepackage{booktabs} 

\pagestyle{empty}

\newcommand{\mycoordinates}
{
\vspace{0.2cm}
\begin{tabular}{|Sc|Sl|} \hline
\Huge Point & \Huge Original \(\rightarrow\) Transformed \\ \hline
\Huge A & \\ \hline
B & \\ \hline
C & \\ \hline
\end{tabular}
}

\begin{document}

\mycoordinates
\vskip 1cm

{\makegapedcells
\begin{tabular}{|c|l|} \hline
\Huge Point & \Huge Original \(\rightarrow\) Transformed \\ \hline
\Huge A & \\ \hline
B & \\ \hline
C & \\ \hline
\end{tabular}}
\vskip 1cm

\begin{tabular}{cl} \toprule
\Huge Point & \Huge Original \(\rightarrow\) Transformed \\ 
\midrule
\Huge A & \\ 
\midrule
B & \\ 
\midrule
C & \\ 
\bottomrule
\end{tabular}

\end{document} 

enter image description here