[Tex/LaTex] \fontsize command not working as expected

fontsfontsizetables

I have some tables in the middle of a document which is in written in 12pt and I'm trying to make them in 10pt. Only the tables. If I write

\begin{table}
\centering
\fontsize{10}{12}
\begin{tabular}{clcc}\hline
Variable & flag & flag & Height \\\hline
$q$ & Specific & a & 46.46\\
$c$ & \CO2 & b & 46.46
\end{tabular}
\end{table}

then only the first column gets passed into 10pt. I have tried everything and the only thing that made it work is

\begin{table}
\centering
\fontsize{10}{12}\selectfont
\begin{tabular}{clcc}\hline
Variable & flag & flag & Height \\\hline
$q$ & Specific & a & 46.46\\
$c$ & \CO2 & b & 46.46
\end{tabular}
\end{table}

This doesn't look like the correct way to do it for me. What the proper way to achieve what I want and why doesn't a simple \fontsize work?

Best Answer

Fonts in LaTeX are characterized by several attributes:

  • encoding
  • family
  • series
  • shape
  • size
  • baseline skip

For each of the attributes there is a low level command

  • \fontencoding
  • \fontfamily
  • \fontseries
  • \fontshape
  • \fontsize

The last command has two arguments, because it sets both the size and the baseline skip.

It would be quite inefficient if each of those command immediately did a font selection, so the system works by first setting the attributes and then applying a \selectfont command.

Higher level commands such as \itshape already do the \selectfont by themselves as well as \small or similar commands.

So your \fontsize{10}{12} declaration is incomplete: some internal parameters are set, but no particular font is chosen. You have to add \selectfont either explicitly or implicitly by means of a higher level command.

In your case, just using \footnotesize would do: when the main body font is 12pt, \footnotesize chooses a 10pt font.

It's always better using a higher level command.