2

I use XeTeX with C-language code inside verbatims. The aim is that my students can perform copy/paste from the resulting PDF document into their programming IDE.

Using XeTeX is great because I can use system fonts instead of LaTeX fonts. I wanted to substitute the typewriter font to the system "Courier" font. I used : \setmonofont[Scale=MatchLowercase,Ligatures=NoCommon}{Courier}

This works great. However, single and double quotes are then replaced by tilted single and double quotes. The result is that it remains in the copy/paste code, that can no longer compile.

Is it possible to ask XeTeX or fontspec or something to use the exact kind of quote used in the verbatim instead of a tilted one ?

Regards ! Mike

3
  • Welcome to TeX.SX! Please post a compilable code example (MWE) that we can copy and paste to help you.
    – TeXnician
    Commented Oct 27, 2017 at 14:41
  • please edit typo NoCommon] not NoCommon}
    – user4686
    Commented Oct 27, 2017 at 15:01
  • I can not reproduce your problem with \begin{verbatim}, (on next line) "Hello", and (on next line) \end{verbatim} and Mac OS system Courier font (which with \XeTeXtracingfonts1 one sees it finds in /System/Library/Fonts/Courier.dfont with the command \setmonofont of your post)
    – user4686
    Commented Oct 27, 2017 at 15:03

1 Answer 1

1

It doesn't happen. I tried to compile the minimal document

\documentclass{article}
\usepackage{fontspec}

\setmonofont[
  Scale=MatchLowercase,
  Ligatures=NoCommon,
]{Courier}

\begin{document}

\begin{verbatim}
"Hello" world 'this' is nice
\end{verbatim}

\end{document}

with TeX Live from release 2012 to 2019/pretest and the output is always

enter image description here

If I copy from the PDF file and paste here, I get

"Hello" world 'this' is nice

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .