30

What is the best way (most proper and general solution) to get rid of the warning

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

by explicitly setting which font should be used for particular family+series+shape combination in edited document?


Bold small-caps are not widely available font-wise. E.g. they are available in CM-Super (which the default font for T1 encoding), but not in overall better Latin Modern.

Let's say I use Latin Modern as the default font (\usepackage{lmodern}). What should be done to make LaTeX fallback to CM-Super in case of bold small caps? (And only in the case of bold small caps, medium small caps should remain typed using Latin Modern.)

29

AFAIK you just need to declare that font shape using \DeclareFontShape. You can just declare the font shape to use the font shape of the standard font. This should lead to the same result as before just without the warning.

Using `lmodern` with `T1` font encoding you get the following warning with `\scshape\bfseries`:
LaTeX Font Warning: Font shape `T1/lmr/bx/sc' undefined
(Font)              using `T1/lmr/bx/n' instead on input line 19.

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

So you need to declare the font shape T1/lmr/bx/sc. As Ulrike pointed out you can substitute another font using the following code:

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{lmodern} \normalfont %to load T1lmr.fd 
\DeclareFontShape{T1}{lmr}{bx}{sc} { <-> ssub * cmr/bx/sc }{}

\begin{document}

{\normalfont normal font}
{\scshape small caps}
{\ttfamily tt family}
{\bfseries bold font}
{\scshape\bfseries bold small caps}% works and uses `cmr` font instead of `lmr`

\end{document}
  • Effort appreciated. It is good as it works for my exemplary case, but at the same time I cannot say I like it, because it requires checking and copying some stuff from .fd file, which I believe should be avoidable, as we're ultimately reusing family+series+shape already defined out there. – przemoc Jul 4 '11 at 1:14
  • Mmm, Adobe Acrobat Reader crashes with the above MWE when I try to display Properties->Fonts! pdffonts actually displays the fonts nicely, so does evince. – Martin Scharrer Jul 4 '11 at 1:15
  • 5
    You can use the sub (or ssub) function to declare the substituation: \usepackage{lmodern} \normalfont %to load T1lmr.fd \DeclareFontShape{T1}{lmr}{bx}{sc} { <-> ssub * cmr/bx/sc }{} – Ulrike Fischer Jul 4 '11 at 9:06
  • 1
    @Ulrike: Thank you! This is exactly what I was looking for and I believe this is the best solution. Could you "transform" your comment into separate answer? You can make it a bit more elaborate if you want. I will happily accept it after day or two. :-) – przemoc Jul 4 '11 at 9:29
  • 1
    Martin can include it in his answer. – Ulrike Fischer Jul 4 '11 at 9:46
4

I was trying to use the technique from the previous comment, until I realised I was using a sans font and that the CM fonts dont have a 'sans serif' bold small caps...

To solve it, I used the helvet package which has them. There is an additional trick as you have to re-load the declaration for \sfdefault as \usepackage{helvet} overwrites it! Then it defaults to lmodern except for the sans small caps where you use helvet...

Just posting the code here in case it is useful to someone!

\documentclass[a4paper,11pt]{article}

\usepackage[T1]{fontenc}

\usepackage{lmodern}
\sffamily %to load T1lmss.fd 

% Load 'sans small caps' from helvet:
\usepackage{helvet}
\sffamily %to load T1phvss.fd 
% Substitute non-existing lmss/bx/sc with phv/bx/sc
\DeclareFontShape{T1}{lmss}{bx}{sc} { <-> ssub * phv/bx/sc }{}
% Can also pick the sans small caps:
\DeclareFontShape{T1}{lmss}{m}{sc} { <-> ssub * phv/m/sc }{}

% Use lmodern to override helvet:
\renewcommand{\rmdefault}{lmr}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}

\begin{document}

This is lmodern roman (lmr) -- default

{\sffamily This is lmodern sans (lmss)}

{\scshape This is small caps from lmodern (lmr)}

{\sffamily \scshape This is sans small caps from helvet (phv)}

{\sffamily \bfseries \scshape This is sans bold small caps from helvet (phv)}

\end{document}

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.