0

Would like to preface this by saying that I am fairly new to Latex. My query is that I would like to change the font for my chapter, section and subsection headings to raleway while keeping the font for the entire document to be EBGaramond. I am adding the code for the same below

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{raleway}
\usepackage{ebgaramond}



\usepackage{titlesec}
\titleformat{\chapter}
  [display]
  {\Huge\bfseries\raleway}
  {\huge\chaptertitlename\space\thechapter}
  {20pt}
  {}

\titleformat*{\section}{\normalfont\Large\bfseries\raleway}
\titleformat*{\subsection}{\normalfont\large\bfseries\raleway}

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\blinddocument
\end{document}

With this code, everything is typesetted to EBGaramond. How do I fix this?

I am using pdflatex compiler in overleaf, if that is useful information.

3
  • I think raleway does not work with pdflatex. Try it with xelatex or lualatex. Feb 24, 2022 at 17:54
  • use \sffamily instead of \raleway to select the font when using pdflatex. Feb 24, 2022 at 18:04
  • Thank you Ulrike!
    – slartibart
    Feb 27, 2022 at 14:31

1 Answer 1

0

The answer is in Ulrike Fischer`s comment. I only added the code for completeness.

Using pdflatex

b

% !TeX TS-program = pdflatex

\documentclass{book}
%\usepackage[T1]{fontenc} % loaded by raleway
\usepackage[extrabold]{raleway}
\usepackage{ebgaramond}

\usepackage{titlesec}
\titleformat{\chapter}
[display]
{\sffamily\Huge\bfseries}
{\huge\chaptertitlename\space\thechapter}
{20pt}
{}

\titleformat*{\section}{\sffamily\Large\bfseries}
\titleformat*{\subsection}{\sffamily\large\bfseries}

\usepackage{kantlipsum}% dummy text

\begin{document}
    \chapter{Heading on level 0}
    \kant[1]

    {\sffamily \small   \kant[1]}       

\end{document}

Using xelatex or lualatex there are more possibilities.

c

% !TeX TS-program = xelatex

\documentclass{book}
%   \RequirePackage{fontspec} % loaded by raleway
\usepackage{raleway}
\usepackage{ebgaramond}

\usepackage{titlesec}
\titleformat{\chapter}
[display]
{\ralewayextra\Huge\bfseries}
{\huge\chaptertitlename\space\thechapter}
{20pt}
{}

\titleformat*{\section}{\ralewayextra\Large\bfseries}
\titleformat*{\subsection}{\ralewayextra\large\bfseries}

\usepackage{kantlipsum}% dummy text

\begin{document}
    \chapter{Heading on level 0}
    \kant[1]
    
    {\ralewaylight \small   \kant[1]}
    
    {\ralewayLF \small  \kant[1]}       

\end{document}

You must log in to answer this question.

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