# \@setfontsize vs. \fontsize

What are the differences between \@setfontsize and \fontsize?

For example, in Martin Scharrer's answer to How to create a newcommand for fontsize? he says:

This is done by calling \@setfontsize which isn't usable in your case.

Why?

The command \@setfontsize has a @ in its name, which means it's a "low level" or, perhaps better, internal command. It shouldn't appear in a normal document apart perhaps in the preamble to make some particular definition.

The definition of \fontsize is

\DeclareRobustCommand{\fontsize}[2]{%
\set@fontsize \baselinestretch {#1}{#2}}


which means that the user level command \fontsize hands control to \set@fontsize. This is a common technique in LaTeX.

The internal command \@setfontsize has a different purpose from \fontsize:

% latex.ltx, line 3611:
\def\@setfontsize#1#2#3{\@nomath#1%
\ifx\protect\@typeset@protect
\let\@currsize#1%
\fi
\fontsize{#2}{#3}\selectfont}


It's typically found in "class option files" such as size10.clo, for instance

\renewcommand\normalsize{%
\@setfontsize\normalsize\@xpt\@xiipt
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
\belowdisplayskip \abovedisplayskip
\let\@listi\@listI}


Let's see what happens when \normalsize is called (most of the times implicitly); LaTeX does

\@setfontsize\normalsize\@xpt\@xiipt


that, in view of the definition above, becomes

\@nomath\normalsize
\ifx\protect\@typeset@protect\let\@currsize\normalsize\fi
\fontsize{\@xpt}{\@xiipt}\selectfont


The first line \normalsize tells LaTeX to disallow \normalsize in math mode; the second line sets \@currsize to be equivalent to \normalsize, but only during normal typesetting (it does nothing, for instance, in write operations). Finally the command \fontsize is called with font size 10pt and baselineskip 12pt, then the font is actually selected.

Thus you see that \@setfontsize is an internal utility and calling it in a document doesn't make sense.

What's the purpose of size10.clo? Classes such as article and report are usually written in a "size independent" way; a size option (that may be the default one) causes LaTeX to read size10.clo, size11.clo or size12.clo (it's bk10.clo, bk11.clo or bk12.clo for the book class). These files set up the font selections and the parameters for lists and many other things that depend on the main body font size.

• Thank you for helpful insight. So \@setfontsize do the same thing as \fontsize plus actualize \@currsize. In my opinion every macro which change font size should actualize \@currsize. So I think using \@setfontsize is better. Am I wrong? – Peter Sarvas May 5 '13 at 6:27
• @PeterSarvas That's what \large, \small and the other commands do, since they are defined in a similar way to \normalsize – egreg May 5 '13 at 9:25
• So when I want define custom macro like \large, \small (e.g. \mysize) should I use \@setfontsize? – Peter Sarvas May 6 '13 at 4:32
• @PeterSarvas It's better, indeed. – egreg May 6 '13 at 8:44
• It brings us to my second question. Martin Scharrer in his answer (link above) says, that he can't use \@setfontsize. Why? – Peter Sarvas May 6 '13 at 10:52