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 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?

share|improve this question
    
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. –  lejon Mar 29 '13 at 11:58

1 Answer 1

up vote 5 down vote accepted

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

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.