# [XeTeX] using open type fonts for fancyvrb verbatim environments

Ross Moore ross.moore at mq.edu.au
Thu Mar 10 22:06:20 CET 2011

Hello Ed,

On 11/03/2011, at 1:40 AM, Ed Morehouse <emorehouse at wesleyan.edu> wrote:

> I'm trying to use an OTF font for text within a fancyvrb Verbatim environment
> but can't figure out how to make it work.  Here's a small example to give an
> idea of what I'm trying to do:
>
>
> \documentclass{article}
> \usepackage{fancyvrb}
> \usepackage{fontspec}
> \newfontfamily \codefont{XITS Math}
>
> \begin{document}
>  \begin{Verbatim}[fontfamily=codefont]
>    ∀ α ∈ ℕ . ∃ β ∈ ℕ . β > α
>  \end{Verbatim}
> \end{document}

> In general, fancyvrb seems to do okay with Unicode, and if I add
> "\setmonofont{XITS Math}" to the preamble and leave away the fontfamily argument
> to the \Verbatim environment, the text renders properly.  The only problem with
> this is that I don't want all verbatim text in XITS Math font, just
> some.

Then define a new environment that changes the mono font just for itself, before calling the Verbatim environment.
Be careful with how you use it, as verbatim-like environments behave slightly differently to other environments, but fancyvrb should have some documentation about how to make such definitions.

>
> I'm running XeLaTeX and all packages from TeXLive-2010 (MacTeX).
>
> Any ideas?
>
> -Ed Morehouse
>

Hope this helps,

Ross