# Single-quote character in LaTeX formatter in Pygments 1.6

Issue #889 new
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.

## Comments (6)

(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 :(

Ah! Sorry about that.

I plan to revive this within the next three weeks. Rather than providing a single monolithic change set, I will roll out the improvements one by one to make review simpler.

I will recreate a wiki when I do so, and change the links above.

Andrew, if you're still interested I think we should target for 2.1 (January, maybe)

Hi! I am at PyCon, and I'd love to help, but I will unfortunately have to work during sprints this year. I'll come say hi.

1. Log in to comment