3

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?

1 Answer 1

3

The two packages fight each other in how to define \sfdefault.

I suggest to first load sourcesanspro and make it \rmdefault. Then you can load montserrat.

\documentclass[a4paper,12pt]{book}

\usepackage[T1]{fontenc}
\usepackage{sectsty}

\usepackage{sourcesanspro}

% set the default font to SourceSansPro
\RenewCommandCopy{\rmdefault}{\sfdefault}

\usepackage[tabular,lining]{montserrat}

\allsectionsfont{\sffamily}

\setlength{\parindent}{0pt} % never indent first line

\begin{document}

\chapter{Introduction}

\section{Why join? \fontname\font}

This document is a sample document to 
test font families and font typefaces.
\fontname\font

\end{document}

The \fontname\font instructions show what font is being used.

enter image description here

Without the default or defaultfam options, the two packages just set \sfdefault. After loading sourcesanspro, we change \rmdefault to what sourcesanspro thinks is \sfdefault. After that we can load montserrat that sets \sfdefault.

8
  • Thank you for the prompt answer. Unfortunately, I get ! Undefined control sequence. l.9 \RenewCommandCopy {\rmdefault}{\sfdefault} ?
    – Chris Peh
    Commented Dec 19, 2022 at 22:17
  • How can I fix that?
    – Chris Peh
    Commented Dec 19, 2022 at 22:19
  • @ChrisPeh Use \renewcommand. But upgrade your TeX distribution.
    – egreg
    Commented Dec 19, 2022 at 22:35
  • It runs. Unfortunately, I'm getting an output now with both times montserrat...
    – Chris Peh
    Commented Dec 20, 2022 at 10:21
  • 2
    @ChrisPeh On GNU/Linux systems I recommend to install the TUG TeX Live. The one that comes with the distribution is usually years behind the current release and, indeed, you have TL 2019, when the current one is 2022.
    – egreg
    Commented Dec 21, 2022 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .