[Tex/LaTex] Beramono in XeTeX

beramonofontsfontspecxetex

I like the beramono font, and I want to use it for code listings (using the listings package). I want the standard CMR tt font for typewriter font in the body of the text.

I could do this using XeLaTeX, by importing beramono using fontspec – but I can't find the proper name of the font! All I can find is (for LaTeX):

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

which is all very well, but it changes all typewriter fonts, not just the ones in the listings. What I want is to use XeLaTeX with something like

\usepackage{fontspec}
\newfontface\lstmono[scale=0.9]{The Proper Name for Beramono}

and then in my listing preamble include

basicstyle=\lstmono

However, I don't know the proper name for beramono. The command fc-list has not been much help. Can beramono be used with XeLaTeX?

Best Answer

Download the ttf version from

http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/1.10/

and save the files in a directory where your system will find the fonts. Then define a typeface

\newfontfamily\Bera{Bitstream Vera Sans Mono}[Scale=0.85]

As an alternative use the file name.

Then you can use listings with

\lstset{basicstyle=\Bera\small,...}

An example:

\documentclass{article}
\usepackage{fontspec}
\usepackage{listings,xcolor}
\newfontfamily\Bera{Bitstream Vera Sans Mono}[Scale=0.85]
\lstset{basicstyle=\Bera\small,keywordstyle=\bfseries,commentstyle=\itshape}
\begin{document}

\begin{lstlisting}[language={[LaTeX]TeX}]
\documentclass{article}% standard class
\usepackage{pst-eps}
\usepackage{graphicx}
\begin{document}
\end{lstlisting}

\texttt{Default monotype} 
\textbf{\texttt{Default bold monotype}} 
\end{document}

enter image description here