[Tex/LaTex] How to scale fonts including sections and subsections

fontsize

I am trying to scale the fonts in my document with the scalefnt package. However it only affects the body text and not the section or subsection headings, as the following example shows:

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{fontenc}

\usepackage{scalefnt}

\begin{document}

\begingroup
\scalefont{2}
\subsection*{Test}

Test
\endgroup


\subsection*{Test}

Test

\end{document}

Output:

Output

Is there any way to make this work or another way to scale all fonts including section and subsection headings by the same factor?

Best Answer

If you're only using \normalsize font and standard sectioning commands, then you could use the sectsty package to easily manipulate font sizes of sectional headings in concert with scalefnt.

The following example, with some modifications, is partly taken from Is it possible to change text color for all headings?:

enter image description here

\documentclass{article}
\usepackage{lmodern,scalefnt,sectsty}% http://ctan.org/pkg/{lmodern,scalefnt,sectsty}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\sectionfont{\color{red}\scalefont{2}}
\subsectionfont{\color{green!80!black}\scalefont{2}}
\subsubsectionfont{\color{blue!50!white}\scalefont{2}}
\AtBeginDocument{\scalefont{2}}
\begin{document}
\section{A section} Hi there
\subsection{A subsection} Some text
\subsubsection{A subsubsection} Some more text
\small Hi there
\end{document}

As can be seen, \small initiates a different (fixed) font size based on the document class option (10pt default in this case), and therefore doesn't correspond to the \scalefont{2} set \AtBeginDocument; the only caveat.