2

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?

6
  • 2
    The \selectfont is indeed required to "activate" the \fontsize macro. Apr 15, 2016 at 17:44
  • For example, see tex.stackexchange.com/questions/25249/… Apr 15, 2016 at 17:48
  • @egreg: Really? I would have staked my life on it. I'll remove it and post another comment. Thanks!
    – Bernard
    Apr 15, 2016 at 18:14
  • But you might as well write \footnotesize. It is equivalent, if the document size is 12pt.
    – Bernard
    Apr 15, 2016 at 18:14
  • @Bernard In size12.clo you find \newcommand\footnotesize{\@setfontsize\footnotesize\@xpt\@xiipt...}
    – egreg
    Apr 15, 2016 at 18:17

1 Answer 1

1

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.

1
  • I preferred using the low-level command because in case the document goes back to being 10pt (as it will someday) then the font in the table will still be the same size. Great answer, though, although I still fail to see what the \fontsize command does if you still have to use a \selectfont command.
    – TomCho
    Apr 15, 2016 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .