I'm using pdfLaTeX and a sans serif family that supports a light (l
) face. I'd like to substitute the default medium (m
) face by l
only when \sffamily
(or \textsf
) is called.
In the next example, egreg's solution is only successfull in changing the \mddefault
for the roman family, but not for sans serif.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\makeatletter
\renewcommand{\mddefault}{\ifx\f@family\sfdefault sbc\else bx\fi}
\makeatother
\setlength\parskip{\baselineskip}\setlength\parindent{0pt}
\begin{document}
\textrm{The brown fox jumps over the lazy dog} \\
{\usefont{T1}{lmr}{m}{n}The brown fox jumps over the lazy dog} \\ % medium
{\usefont{T1}{lmr}{b}{n}The brown fox jumps over the lazy dog} \\ % bold
{\usefont{T1}{lmr}{bx}{n}The brown fox jumps over the lazy dog} % bold expanded
\textsf{The brown fox jumps over the lazy dog} \\
{\usefont{T1}{lmss}{sbc}{n}The brown fox jumps over the lazy dog}\\ % semi bold condensed
{\usefont{T1}{lmss}{m}{n}The brown fox jumps over the lazy dog} \\ % medium
{\usefont{T1}{lmss}{bx}{n}The brown fox jumps over the lazy dog} % bold expanded
\end{document}
Then I tried to use \DeclareFontShape
, but I always get the same type of error. For instance, using an example of pg 425 of The LaTeX Companion :
\documentclass{article}
\DeclareFontShape{0T1}{cmss}{m}{it}{ <-> sub * cmss/m/sl }{}
\begin{document}
text
\end{document}
I get the error:
Best Answer
There are a number of issues to solve. The first is that redefining
\mddefault
in that way will not help, because\mddefault
is not executed as part of\sffamily
. The second is a traditional puzzle caused by some command being\long
in a context and not\long
in others.A possible workaround is to redefine
\curr@fontshape
, that provides LaTeX with the current font attributes for later processing by NFSS.I used Source Sans Pro because it has the "light" series. More tests are needed if other font attributes need to be changed depending on the current family.