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 looking for condensed mono spaced (typewriter) fonts to typeset program listings with pdflatex. The fonts should have the common shapes (up and italic or slanted) and series (normal and bold). Any suggestions?

share|improve this question
    
By "typewriter" font, I assume you mean monospaced, right? Separately, will you be running pdflatex, xelatex, or lualatex? –  Mico Mar 10 '12 at 3:50
    
@Mico Yes, I mean mono spaced fonts. I will be running pdflatex. –  Romildo Mar 10 '12 at 8:38
add comment

4 Answers 4

up vote 10 down vote accepted

Latin Modern ha a condensed version of the typewriter font:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{lipsum}

\begin{document}
\ttfamily\lipsum[1]

\fontseries{lc}\selectfont
\lipsum[1]

\end{document}

enter image description here

If you need the text justified, you have to modify the \fontdimenX values

share|improve this answer
add comment

There is beramono:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[scaled=.83]{beramono}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\ttfamily\lipsum[1]

\end{document}
share|improve this answer
add comment

Instead of looking for condensed fonts, you can also just change the size of the default font. I find that Latin Modern in \footnotesize looks quite good in listings:

\documentclass{article}

\usepackage{lmodern}
\usepackage{lipsum}
\usepackage{listings}

\lstset{%
  basicstyle=\footnotesize\ttfamily,%
  numbers=left,%
  numberstyle=\footnotesize,%
  tabsize=2%
}

\begin{document}

\lipsum[1]

\begin{lstlisting}[language=C]
#include <stdio.h>

int main(void)
{
    printf("Hello World!\n");
}
\end{lstlisting}

\end{document}

Latin Modern typewriter font has normal and bold series, but the difference is subtle. You can try passing the lighttt option to the lmodern package for more distinction.

You can also browse The LaTeX Font Catalogue.

share|improve this answer
add comment

I do not know any free fonts satisfying your requirements. If you can consider non free fonts. I would recommend The Sans Mono Condensed Font designed by Lucas de Groot specifically for typesetting program code: http://www.lucasfonts.com/fonts/thesansmono/thesansmono-condensed/. Years ago I wrote LaTeX support package for it: http://www.ctan.org/pkg/thsmc. Of course XeTeX can use this font directly.

share|improve this answer
add comment

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.