Tell me more ×
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
2  
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
1  
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
show 2 more comments

1 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

share|improve this answer

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.