Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Basically I want

\mint{python}|'banana'|

to produce straight single quotes, rather than the curly ones it normally produces (in pdflatex).

share|improve this question
    
Not quite related to the q., but searching for the problem led me here: Outside of verbatim, you can use \char18 and \char13 to get modified ` and ' characters. –  Mohan Nov 20 '12 at 11:12

1 Answer 1

up vote 18 down vote accepted

You can use the package upquote. Note the package loads the package textcomp

The package upquote works also with listings.

% !TEX program  = pdflatex --shell-escape

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{minted}
\usepackage{upquote}
\begin{document}
\mint[fontfamily=tt]{python}|'banana'|
\end{document}

The result:

enter image description here


If you are using pygmentize version 1.6 that the package upquote can't do its job. To fix this issue you can use the following hack:

\listfiles
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{minted}
\usepackage{upquote}
\AtBeginDocument{%
\def\PYZsq{\textquotesingle}%
}
\begin{document}
\mint[fontfamily=tt]{python}|'banana'|
\end{document}

Note if you are working with XeLaTeX or LuaLaTeX the hack isn't needed.

share|improve this answer
1  
Awesome. Thanks! –  nimish Mar 9 '12 at 22:49
3  
For anyone who comes across this later: the upquote package modifies all verbatim text (\verb and the verbatim environment) to render ' and ` as the upright versions, not the “smart” and . Since (as I understand it) minted and listings rely on fancyvrb, which itself calls out to verbatim text under the hood, this has the desired effect. –  Antal S-Z Sep 27 '12 at 6:02
    
On Mac OS 10.8.3 (if that matters), that still gives me curly quotes... –  Jubobs May 30 '13 at 15:22
    
@Jubobs: Do you working with TL2013? –  Marco Daniel May 30 '13 at 15:24
    
@MarcoDaniel This is embarrassing -_- but I'm not sure which version of TeX Live I have. How do I check that? Would the TeX Live Utility tell me that or do I need to type some code in the terminal? –  Jubobs May 30 '13 at 22:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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