Issue #889 new

# Single-quote character in LaTeX formatter in Pygments 1.6

Anonymous created an issue

Before Pygments 1.6, there were no TeX macros for quote characters. In 1.6, there are macros for both the single-quote and the double-quote characters.

\def\PYZsq{\char\'}
\def\PYZdq{\char\"}


The double-quote character seems to work fine under all LaTeX engines (pdftex, luatex, xetex). However, the single-quote character is problematic under pdftex, which is probably the most-used engine. It appears as a right-hand curly quote, ’, rather than a straight quote, '. A standard LaTeX way to get straight quotes in typeset code is to use the upquote package (http://www.ctan.org/pkg/upquote), but it doesn't work because of the way Pygments is hardcoding the quote character. This is requiring TeX users to resort to hacking the Pygments macros.

Is there a particular reason that the quote character macros were added? If so, then going back to the old approach (no macros) won't be an option.

If quote macros are needed, an alternative would be

\def\PYZsq{\textquotesingle}


However, this will only work with pdftex if the textcomp package is used.

Another possibility is to use \scantokens:

\def\PYGdefaultZsq{\scantokens{'}}


That will require etex, but it's built into all current TeX distributions.

Another option is to define the macro conditionally, with code inspired by the upquote package.

(Newly updated) pull request #215 looks to fix this issue (and more), using the examples you supplied.

If you're curious about the new options in the fork, I've written a page on the wiki about it (based quite heavily on the material provided here).

Andrew, did you want to revive this? Wiki 404's :(