30

I want to use a different monospaced font for \texttt. I'm particularly fond of Bitstream Vera Sans Mono. If possible, not with XeTeX, since I'm not yet really familiar with it. Solutions using XeTeX would still be welcome, of course.

I hope this doesn't violate the one-question policy:

  1. How do I change the monospaced fonts invoked by \texttt{foo bar baz...}?
  2. Where can I find a list of other fonts that I can use without invoking XeTeX?
2
  • Since the question is explicitly not about xetex, I removed the xetex tag. Also it was decided that the latex tag should not be used.
    – Caramdir
    Commented Nov 16, 2010 at 5:34
  • A nice sans serif monospace font is Source Code Pro from Google. You can us it just by importing it: \usepackage{sourcecodepro} See also here.
    – Gepeto97
    Commented Nov 24, 2020 at 12:22

1 Answer 1

28

for font support out of the box with your tex distribution, check out https://tug.org/FontCatalogue/

for monospaced, inconsolata is quite nice i think.

install the package, then load it up:

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

A working example looks like this:

\documentclass{article}

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

\begin{document}

this is a \texttt{mono spaced font example}.

\end{document}

bera mono is somewhat close to bitstream mono. load it up like this:

\usepackage[T1]{fontenc}
\usepackage[scaled]{beramono}

for xetex or xelatex, you need the fontspec package, and the font installed to your system, then load the font with fontspec:

\usepackage{fontspec}
\setmonofont[Mapping=tex-text]{Courier New}

A working example in xelatex looks like this:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[a4paper,11pt,final,openright,twoside]{memoir}
\RequireXeTeX %Force XeTeX check

%XeLaTeX packages
\usepackage{xltxtra}
\usepackage{fontspec} %Font package
\usepackage{xunicode}


%Select fonts
\setmainfont[Mapping=tex-text]{Minion Pro}
\setsansfont[Mapping=tex-text]{Myriad Pro}
\setmonofont{Bitstream Vera Mono}

\begin{document}

\textrm{Ya! System} \texttt{fonts are} \textsf{so nice!}

\end{document}
3
  • 5
    Perhaps an example with \setmonofont would make more sense given the question? Commented Nov 16, 2010 at 1:13
  • Bera Mono is Bitstream Vera Mono, isn't it? I thought "Bera" was just a contraction of Bistream Vera.
    – frabjous
    Commented Nov 16, 2010 at 2:05
  • Added some more examples, and one with \setmonofont like Will suggested. Bera and Bitstream might be the same thing. I wasn't sure, and I'm still not :P
    – Mica
    Commented Nov 16, 2010 at 2:07

You must log in to answer this question.

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