5

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
7

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.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.