[Tex/LaTex] How to remove the warnings “Font shape `OT1/cmss/m/n’ in size <4> not available” and “Size substitutions with differences” in beamer

beamerfontswarnings

LaTeX Font Warning: Font shape `OT1/cmss/m/n' in size <4> not available
LaTeX Font Warning: Size substitutions with differences

I am using the files from http://www.poirrier.be/~jean-etienne/info/latexbeamer/latex-beamer.tar.gz.

Alternatively, for a minimal working example, the presentation

\documentclass{beamer}
\begin{document}

\begin{frame}
\titlepage 
\end{frame}

\end{document} 

produces the warnings.


How to remove the above 2 warnings?

Best Answer

Add

\usepackage{lmodern}

to your document preamble.

Fonts are typically available only in certain sizes/increments. As an example, the basic article document class loads only the following sizes (from size10.clo):

  • \tiny @ 5pt;
  • \scriptsize @ 7pt;
  • \footnotesize @ 8pt;
  • \small @ 9pt;
  • \normalsize @ 10pt;
  • \large @ 12pt;
  • \Large @ 14.4pt;
  • \LARGE @ 17.28pt;
  • \huge @ 20.74pt; and
  • \Huge @ 24.88pt

So, requesting a 15pt font size using something like

\documentclass{article}
\begin{document}
\fontsize{15}{18}\selectfont Hello world.
\end{document}

leads to LaTeX complaining in the .log file:

LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <15> not available
(Font)              size <14.4> substituted on input line 3.
...
LaTeX Font Warning: Size substitutions with differences
(Font)              up to 0.6pt have occurred.

Using lmodern removes this restriction by allowing font sizes at arbitrary sizes. For more on font size requirements, see Fonts at arbitrary sizes.

Related Question