# \Huge Text in Tabular touches table border

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}


• Add \extrarowheight or see booktabs or makecell or add additional spacing manually at the end of the row or ... ? – cfr Oct 4 '16 at 22:33
• Ok, I will try those things. – WeCanLearnAnything Oct 4 '16 at 22:43
• Why would tabular's default NOT give enough space to the contents of the cell? Even in row B and C of the picture, there is more space underneath the text than above. Why? And is there some place I can learn all of these defaults? – WeCanLearnAnything Oct 4 '16 at 22:43
• the default is normal line spacing (basically the height and depth of \strut so the space below is the normal depth to make room for \normalsize descenders, the fact that the capital letters are closer to the top than that is just a feature of the font design and the baseline spacing chosen to go with it, essentially (without the \hline) you would see the same spacing in paragraph text – David Carlisle Oct 4 '16 at 22:47
• You could read booktabs's manual which has quite a lot to say about this in general, even if not in particular. – cfr Oct 4 '16 at 22:49

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}


LaTeX uses a \strut for setting the cell's height; however the \strut is computed before starting the table.

Just add a \strut after \Huge (one cell in the row where \Huge appears suffices).

\documentclass{article}

\pagestyle{empty}

\begin{document}

\begin{tabular}{|c|l|} \hline
\Huge \strut Point & \Huge Original $$\rightarrow$$ Transformed \\ \hline
\Huge \strut A & \\ \hline
B & \\ \hline
C & \\ \hline
\end{tabular}

\end{document}


It is probably simplest to set up the table for \Huge and just have smaller text where needed. (option (b))

\documentclass{article}
\usepackage{array}
\pagestyle{empty}

\newcommand{\mycoordinates}
{\par
\vspace{0.2cm}
\begin{tabular}{|c|l|} \hline
\Huge Point & \Huge Original $$\rightarrow$$ Transformed \\ \hline
\Huge A & \\ \hline
B & \\ \hline
C & \\ \hline
\end{tabular}%%
}
\newcommand{\mycoordinatesb}
{{\par\Huge
\vspace{0.2cm}
\begin{tabular}{|c|l|} \hline
Point &  Original $$\rightarrow$$ Transformed \\ \hline
A & \\ \hline
\normalsize B & \\ \hline
\normalsize C & \\ \hline
\end{tabular}%%
}}
\newcommand{\mycoordinatesc}
{{\setlength\extrarowheight{17pt}\par
\vspace{0.2cm}
\begin{tabular}{|c|l|} \hline
\Huge Point & \Huge Original $$\rightarrow$$ Transformed \\ \hline
\Huge A & \\ \hline
B & \\ \hline
C & \\ \hline
\end{tabular}%%
}}
\newcommand{\mycoordinatesd}
{{\renewcommand\arraystretch{2.5}\par
\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
\mycoordinatesb
\mycoordinatesc
\mycoordinatesd

\end{document}