# Change font of footnotesized texts

I am trying to redefine the footnotesize command to be displayed in another font than the rest of the document's Computer Modern. Specifically the font libertine. However I find it tricky. Can someone help me?

Here is the unaltered \footnotesize code:

\makeatletter
\renewcommand\footnotesize{%
\@setfontsize\footnotesize\@ixpt{11}%
\abovedisplayskip 8\p@ \@plus2\p@ \@minus4\p@
\abovedisplayshortskip \z@ \@plus\p@
\belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 4\p@ \@plus2\p@ \@minus2\p@
\parsep 2\p@ \@plus\p@ \@minus\p@
\itemsep \parsep}%
\belowdisplayskip \abovedisplayskip
}
\makeatother

• Sep 20, 2018 at 22:31

You can find out what LaTeX thinks the Libertine font is called:

\documentclass{article}
\usepackage{libertine}
\begin{document}
\rmdefault
\end{document}


Upon compiling this test, you'll discover that the internal name is

LinuxLibertineT-TLF

Fine, now we can patch \footnotesize:

\documentclass{article}
\usepackage{etoolbox}

\apptocmd{\footnotesize}
{\fontfamily{LinuxLibertineT-TLF}\selectfont} % choose Libertine before typesetting
{}{}

\setlength{\textheight}{1cm} % just to make a smaller picture

\begin{document}

This is some text in the default
font\footnote{This is a footnote in Linux Libertine}

\end{document}


Be careful that not only footnotes would be typeset in Libertine, but everything in the scope of a \footnotesize declaration.

On the other hand, now that you see the output, you are likely to go back and remove the \apptocmd instruction. ;-)

• The font is not changing back to cmr after initiating a \footnotesize. I have to manually add \fontfamily{cmr}\selectfont after each \footnotesize. Is there a workaround for this as well? Sep 26, 2018 at 8:38
• @E.l4d3 How do you initiate a \footnotesize? If I do aaa {\footnotesize bbb ccc} ddd, then aaa and ddd are in the same font. Sep 26, 2018 at 8:40
• Usually without encapsulating {}. It indeed works when doing so, thank you! Sep 26, 2018 at 8:48
• @E.l4d3 That's the best way (but remember \par before } if the \footnotesize text is a full paragraph. By the way, LaTeX has \normalfont and \normalsize to restore the initial fonts. Sep 26, 2018 at 8:53

You have to load libertine and restore the previous font after that, then you just have to patch-in the \libertine1 command provided by the package into the \footnotesize command. I chose to use \g@addto@macro instead of completely redefining \footnotesize so that the patch (theoretically) doesn't depend on the class or font size being used.

\documentclass{article}
\usepackage[a6paper]{geometry} % Just for the example

\let\saverm\rmdefault % \
\let\savesf\sfdefault % | Save the current font
\let\savett\ttdefault % /
\let\rmdefault\saverm % \
\let\sfdefault\savesf % | Restore the font
\let\ttdefault\savett % /

\usepackage[nopar]{lipsum} % For dummy text

\makeatletter
\g@addto@macro\footnotesize\libertine % <--- Patching \libertine in
\makeatother

\begin{document}

\lipsum[2]\footnote{\lipsum[4]}

\end{document}


1 For people that want to use this with other fonts: not all packages define a command to change the font like libertine does, so it may not be that easy, but it's certainly doable.

• Thank you. A preferable solution if I don't want to redefine footnotesize for another project. Sep 23, 2018 at 13:10