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.

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?

share|improve this question
3  
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
5  
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
1  
There's an Inconsolata fork with straight quotes, which you could use with XeLaTeX/LuaLaTeX. –  doncherry Dec 8 '12 at 16:18

2 Answers 2

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

share|improve this answer

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}

enter image description here

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

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

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.