2

I am able to set default text font using \newfontfamily\mainfont{}.

Here is an example.

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\mainfont{DejaVu Sans}
\begin{document}
Foo
\texttt{Bar}
\end{document}

How can I similarly set the default monospace font that is used for text rendered with \texttt{}?

1
  • The main font is set with \setmainfont{DejaVu Sans}, the monospaced font (for \texttt) with \setmonofont{...<font name>...}
    – egreg
    Aug 28, 2016 at 18:08

1 Answer 1

4

Read the main part of fontspec documentation. At page 7, you find

enter image description here

So you should do

\documentclass{article}
\usepackage{fontspec}
\setmainfont{DejaVu Sans}
\setmonofont{Libertinus Mono}[
  Scale=MatchLowercase
] % or whatever font you prefer

\begin{document}

Foo
\texttt{Bar}

\end{document}

enter image description here

You must log in to answer this question.

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