I'm writing a handbook for an organisation who has specific fonts (Montserrat for Titles and headings; Source Sans Pro for the text).
I can change the font to either of them using
https://tug.org/FontCatalogue/montserratregular/ and
https://tug.org/FontCatalogue/sourcesanspro/, respectively.
But I don't know how to get it into \allsectionsfont
Or into \fontfamily
because the examples I found are for the "standard" fonts.
\documentclass[a4paper,12p]{book}
\usepackage[T1]{fontenc}
\usepackage[default]{sourcesanspro}
%\usepackage[defaultfam,tabular,lining]{montserrat} %% Option 'defaultfam'
%%% only if the base font of the document is to be sans serif
%\usepackage[T1]{fontenc}
\renewcommand*\oldstylenums[1]{{\fontfamily{Montserrat-TOsF}\selectfont #1}}
\usepackage{sectsty}
\allsectionsfont{\sffamily}
\begin{document}
\setlength{\parindent}{0pt} % never indent first line
\chapter{Introduction}
\section{Why join?}
This document is a sample document to
test font families and font typefaces.\\
{\fontfamily{cmss}\selectfont
This text uses a different font typeface
}
\end{document}
How do I need to change my code?
Best Answer
The two packages fight each other in how to define
\sfdefault
.I suggest to first load
sourcesanspro
and make it\rmdefault
. Then you can loadmontserrat
.The
\fontname\font
instructions show what font is being used.Without the
default
ordefaultfam
options, the two packages just set\sfdefault
. After loadingsourcesanspro
, we change\rmdefault
to whatsourcesanspro
thinks is\sfdefault
. After that we can loadmontserrat
that sets\sfdefault
.