# Using lmodern as default teletype font

I would like to use lmodern as my default teletype font, while using other fonts for sans etc.

So far I have

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[defaultsans]{cantarell}
\usepackage{lmodern}
\renewcommand*\ttdefault{???}

\begin{document}
{\ttfamily Hello in lmodern }
\end{document}


What do I have to replace the ??? with in order for the lmodern to be used as the default teletype?

-
Nothing, just remove \renewcommand*\ttdefault{???} – David Carlisle Mar 29 '13 at 11:35
Loading lmodern after cantarell will override the choice of the sans serif font; change the loading order, if you want Cantarell as sans serif font. As David says, nothing is necessary for the monospaced font. – egreg Mar 29 '13 at 11:41
Good tip on the load order. Thanks. – kasperhj Mar 29 '13 at 11:58

The cantarell package with the defaultsans option sets the sans serif font to Cantarell by redefining \sfdefault. However, lmodern does

\renewcommand{\sfdefault}{lmss}


so loading it after cantarell will override the specification made by this package. The lmodern package sets \ttdefault to lmtt (Latin Modern Typewriter), so you get served by

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[defaultsans]{cantarell}

\begin{document}
{\sffamily Hello in Cantarell}

{\ttfamily Hello in lmodern}
\end{document}


without doing anything for \ttdefault.

-