TransWikia.com

How to change bold font to Computer Modern when using Alegreya Package

TeX - LaTeX Asked by Dennis Chen on September 1, 2021

I want to use the Alegreya font in a book for chapter headings, but would like to use Computer Modern for the body text. The thing is, usepackage{Alegreya} makes the default font Alegreya. To set the body font back to Computer Modern I did this:

renewcommandrmdefault{lmr}

The thing is, when I try to use bold font it stays in Alegreya. I would rather it not do that, so how can I set boldface font to Computer Modern?

MWE:

documentclass{article}

RequirePackage[utf8]{inputenc}
RequirePackage{pifont}
RequirePackage[T1]{fontenc}

usepackage{Alegreya}
renewcommandrmdefault{lmr}

begin{document}
textbf{This is in Alegreya.} This is Computer Modern.
end{document}

Output:

Output of the LaTeX code.

Thanks for your time.

One Answer

If you use alegreya, you're changing familydefault and changing rmdefault cannot give you Latin Modern everywhere except in chapter titles.

If you make the simple document

documentclass{article}
usepackage{Alegreya}

begin{document}

familydefault

end{document}

upon compiling it you will see

Alegreya-LF

That's the key for the following.

documentclass{book}
usepackage{sectsty}

DeclareRobustCommand{alegreyafont}{fontfamily{Alegreya-LF}selectfont}
chapterfont{alegreyafont}


begin{document}

chapter{This is in Alegreya}

This is not.

end{document}

There are other ways to change the chapter heading, sectsty offers the simplest interface.

enter image description here

Correct answer by egreg on September 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP