1

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
1

2 Answers 2

1

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.

enter image description here

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

4
  • 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?
    – E. l4d3
    Sep 26, 2018 at 8:38
  • 1
    @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.
    – egreg
    Sep 26, 2018 at 8:40
  • Usually without encapsulating {}. It indeed works when doing so, thank you!
    – E. l4d3
    Sep 26, 2018 at 8:48
  • 1
    @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.
    – egreg
    Sep 26, 2018 at 8:53
1

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.

enter image description here

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

\let\saverm\rmdefault % \
\let\savesf\sfdefault % | Save the current font
\let\savett\ttdefault % /
\usepackage{libertine} % Load libertine
\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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.