[XeTeX] Character mangling in verbatim environments

Jonathan Kew jfkthame at googlemail.com
Mon Jul 6 21:28:01 CEST 2009

On 6 Jul 2009, at 19:37, Brian Aydemir wrote:

> Hi everyone,
> I have a verbatim environment with text that includes character  
> sequences such as
> [1] --- (three dashes in a row)
> [2] -- (two dashes in a row)
> [3] '' (two single quotes)
> Outside a verbatim environment, LaTeX will typeset these as an em- 
> dash, en-dash, and a double quote.  Inside a verbatim environment, I  
> expect these sequences to be typeset as they are.
> When I use XeLaTeX, these sequences are still typeset as an em-dash  
> and so on inside a verbatim environment.  Does anyone here have any  
> ideas as to what is going on?  I feel like I might have read about  
> this somewhere, but I can't find where.

In general, you'll get better responses if you provide a minimal but  
complete example to show exactly what you're doing.

However, I think I can guess: I suspect that the font you're using (in  
the verbatim environment) was loaded via fontspec, probably with  
\setmonofont, and you specified the [tex-text] mapping, either in the  
\setmonofont declaration itself or with \defaultfontfeatures. If you  
want "---" to remain three separate hyphens, etc., then you *don't*  
want [tex-text], which replaces those sequences with single Unicode  
characters, to be applied to your monospaced font.

So remove that option from \setmonofont, or put your \setmonofont  
command before your \defaultfontfeatures.


More information about the XeTeX mailing list