24

Basically I want

\mint{python}|'banana'|

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

Marco Daniel
  • 95,681
nimish
  • 415
  • 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 Answers1

26

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.

Marco Daniel
  • 95,681