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.

Comments (4)

  1. Andrew Pinkham

    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.

  2. Log in to comment