Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Ran into some weirdness with fancyvrb, helvetica and _. Here's a MWE (for me):

\documentclass{article}
\usepackage{fancyvrb}

\begin{document}

\begin{Verbatim}[fontfamily=helvetica]
Oh no! It's a `_'. `\_' not much better.
\end{Verbatim}

\end{document}

Without any warnings or apologies, it produces

...i.e., missing a couple of underscores. Strange thing is, it works fine for fontfamily=courier.

Anyone come across anything like this before?

I'm not commited to fancyvrb so if a work-around is awkward, would happily take suggestions for another helvetica/sans-serif verbatim environment which would handle underscores.

share|improve this question
1  
For posterity, I've just realised that this problem is not specific to fancyvrb, but rather of \sffamily (even in plain text). No biggie though: see Gonzalo's solution below. –  badroit Jun 22 '11 at 0:53
add comment

1 Answer

up vote 7 down vote accepted

Use the Cork encoding:

\usepackage[T1]{fontenc}

The following

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}

\begin{document}

\begin{Verbatim}[fontfamily=helvetica]
Oh no! It's a `_'. `\_' not much better.
\end{Verbatim}

\end{document}

produces the expected result:

share|improve this answer
    
Cheers! Works like a charm. –  badroit Jun 22 '11 at 0:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.