I'm currently working on my dissertation and am using Palatino for text with the Euler font for mathematics. As part of my work I'll be presenting quite a few code examples, and was wondering if someone could suggest a good monospace font to go with them. As an alternative I was thinking of using the Concrete Roman and Euler font package (ala Knuth's Concrete Mathematics).
Asked
Active
Viewed 7.0k times
42
2 Answers
34
Inconsolata might be a choice. There is also a package for TeX support.
It is a font "designed for code listings and the like, in print," posing itself as a better alternative since many other fonts are designed for screen and not for the high resolutions in print.
\documentclass{article}
\usepackage{inconsolata}
\begin{document}
\texttt{This is Inconsolata.}
\end{document}
As seen it replaces the \tt, but this behavior can be changed.
Nicolas Dudebout
- 1,078
Henrik Hansen
- 2,927
-
It's a nice font, but I find slightly disturbing the fact that the " is slanted to the right... It looks weird when surrounding a string. – antoine Oct 14 '15 at 00:31
-
On Windows with TexWorks, you must install the font separately on the machine. Otherwise, this sample is producing an AccessViolation crash in miktex-ttf2pk.exe. I reported the crash here : https://github.com/MiKTeX/miktex/issues/513 – Kevin Coulombe Apr 26 '20 at 15:11
-
To get upright quotes in a
\verb(but not in\texttt) you can use thevarquoption:\usepackage[varqu]{inconsolata}. To get them everywhere you need to specify the "stylistic set":\setmonofont[StylisticSet=3]{Inconsolatazi4}. – TheBamf Jan 04 '23 at 11:53
16
I personally think that Knuth's typewriter fonts are still very good, an alternative is charter and bera mono if you can get them.
\usepackage[charter]{mathdesign}
\def\rmdefault{bch} % not scaled
\def\ttdefault{blg}
Also check Different approach to literate programming for LaTeX for some typesetting settings for listings.
-
1If
blgis a monospaced font, shouldn't\texttt{....................}\par \texttt{xxxxxxxxxxxxxxxxxxx.}produce two equally wide lines? – Steven B. Segletes Jul 26 '16 at 14:12 -
-
1Even
\texttt{mmmmmmmmmmmmmmmmmmm}\par \texttt{xxxxxxxxxxxxxxxxxxx}is not equal width, where punctuation is not involved. – Steven B. Segletes Jul 26 '16 at 16:26 -
10@StevenB.Segletes its only monospaced between mindnight and 2 am. Also the wind has to come from west – BlueWizard Nov 30 '16 at 12:44
listingspackage to maintain column alignment (if needed). Palatino Sans might also be a very nice option (if you use XeLaTeX). – mforbes Apr 05 '12 at 07:31