[Tex/LaTex] Minted+Inconsolata: Straight Quotes

fontsmintedpunctuation

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:

Example string with badly-shaped 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:

Example string which erroneously displays no quotes, using Inconsolata font

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:

Example string with straight quotes, using tt font

I'm not sure what's going on.

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

Best Answer

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
\g@addto@macro\@noligs
   {\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}

enter image description here

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}}
\g@addto@macro\@noligs
   {\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}

enter image description here

Related Question