4

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.

  • 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
7

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:

  • Cheers! Works like a charm. – badroit Jun 22 '11 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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