# Minted+Inconsolata: Straight Quotes

I am using minted to display my source code and the Inconsolata package to set the output font. Unfortunately, this produces the following ugly result (note the direction of the quote marks:

Figuring this was a bad attempt on LaTeX's part to use smart quotes, I tried using the upquote package. This produced the following:

Using this MWE:

\documentclass{article}
\usepackage{minted}
\usepackage{inconsolata}
\usepackage{upquote}
\begin{document}

\begin{minted}{matlab}
disp('This string should have straight quotes!');
\end{minted}
\end{document}

Removing the Inconsolata package produces a typographically-acceptable result, but, alas, not in the Inconsolata font:

I'm not sure what's going on.

Why can't I have the font I want AND the appropriate quotes? Any thoughts?

-
The Inconsolata font doesn't have a straight quote character. :( –  egreg Dec 7 '12 at 13:25
... which the log file produced by your MWE tells you: Missing character: There is no ' in font ts1-inconsolata!. –  Christian Clason Dec 7 '12 at 13:26
An alternative is the Droid Sans Mono font (provided by droidmono package) which has straight quotes and looks somewhat similar. –  Christian Clason Dec 7 '12 at 13:29
What the hell, Inconsolata! That font was designed for typesetting code. No straight quotes? The font designer was a master troll. –  Konrad Rudolph Dec 8 '12 at 12:36
There's an Inconsolata fork with straight quotes, which you could use with XeLaTeX/LuaLaTeX. –  doncherry Dec 8 '12 at 16:18

The Inconsolata font doesn't have a straight quote character, as testified by the lines

Missing character: There is no ' in font ts1-inconsolata!

in your .log file. You can work around this by using the cmtt font and doing similarly to what upquote does:

\documentclass{article}
\usepackage{minted}
\usepackage{inconsolata}

\begingroup
\makeatletter
\catcode'=\active
\catcode=\active
{\def'{{\fontencoding{TS1}\fontfamily{cmtt}\selectfont\textquotesingle}}%
\def{{\fontencoding{TS1}\fontfamily{cmtt}\selectfont\textasciigrave}}%
}
\endgroup

\begin{document}

\begin{minted}{matlab}
disp('This string should have straight quotes!');
\end{minted}
\end{document}

Maybe the quotes should be raised a bit:

\documentclass{article}
\usepackage{minted}
\usepackage{inconsolata}

\begingroup
\makeatletter
\catcode'=\active
\catcode=\active
\gdef\raise@quotes#1{\raisebox{.1ex}{\fontencoding{TS1}\fontfamily{cmtt}\selectfont#1}}
{\def'{\raise@quotes{\textquotesingle}}%
\def{\raise@quotes{\textasciigrave}}%
}
\endgroup

\begin{document}

\begin{minted}{matlab}
disp('This string should have straight quotes!');
\end{minted}
\end{document}

-

There is (as of 2013-06-14) a new version of the inconsolata package by Michael Sharpe, called inconsolata-zi4, that provides a font with a straight quote which can be automatically used in verbatim environments (using upquote). (Currently, the new package has replaced inconsolata on CTAN, so use caution in updating; see this question.) With the new package, this works as expected:

\documentclass{article}
\usepackage{minted}
\usepackage[varqu]{zi4}%   updated inconsolata with variant upquotes
\AtBeginDocument{%         needed for pygmentize 1.6
\def\PYZsq{\textquotesingle}%
}
\begin{document}
\begin{minted}[fontfamily=zi4]{matlab}
disp('This string should have straight quotes!');
\end{minted}
\end{document}

(The \def to make upquote work with recent pygments is taken from this answer.)

-
Good news! However, I'd have preferred if the package name had been kept, for backward compatibility. –  egreg Jun 24 at 17:26
The latest version (2013-07-13) now comes with an inconsolata.sty file for backward compatibility. –  Christian Clason Aug 12 at 19:56