TransWikia.com

How to set the default typewriter font?

TeX - LaTeX Asked by workerjoe on May 17, 2021

I’d like to select a new font for the monospaced text such as those parts within a texttt{} and code snippets in the minted context. (As far as I can tell, minted just uses the document’s default typewriter font, so I don’t think I need to touch its settings.) I just want to change to another monospaced font that looks all right and has a normal tilde character. How do I do that?

3 Answers

It's the ttdefault command which normally takes care of this.

documentclass{article}
begin{document}
texttt{How to use a typewriter font}% CM default typewriter font
par
renewcommandttdefault{cmvtt} % selects CM typewriter proportional font
texttt{How to use a typewriter font}
par
renewcommand{ttdefault}{pcr} % selects Courier font
texttt{How to use a typewriter font}      
end{document}

enter image description here

But indeed it's usually best to let dedicated packages as beramamono do this, since there can be a lot of subtleties behind fonts (of which I'm often not aware myself :-)

Correct answer by Franck Pastor on May 17, 2021

usepackage[scaled=0.8]{FiraMono}

Put the above line in the preamble of your document, i.e. immediately after documentclass. That's it!

Concerning the related question of what font to choose, see my answer at
Alternative monospace fonts.

Reference:
https://tug.org/FontCatalogue/typewriterfonts.html

Answered by Henke on May 17, 2021

Since this just got bumped back up to the front page, I’ll add for completeness: in fontspec, use setmonofont.

Answered by Davislor on May 17, 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