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.

How do I change a font for a latex document?

I am using the \documentclass{article}, which sets the document in a serif font. I also declared \usepacke{helvet}, since thats the font I would like to use as a sans-serif. But how do I get latex to actually set the document in a sans-serif font?

Also, I am using the package lslisting to format code-listings. How can I set my document,so that all code is set in a separate font, e.g. courier or any other typewriter font?

share|improve this question
2  
Duplicate of this question? –  Lev Bishop Nov 4 '10 at 4:39
    
It is a duplicate, but I'm not voting to close it because of the additional lstlisting question. –  Will Robertson Nov 4 '10 at 23:18

1 Answer 1

up vote 8 down vote accepted

You want to change the default family to be the sans serif family.

\renewcommand\familydefault{\sfdefault}

does exactly that.

Concerning your other question,

\lstset{basicstyle=\ttfamily}

make all code to be typeset in the active typewriter family, which is by default Computer Modern Typewriter. You can change that to Courier with \usepackage{courier}, just as you select Helvetica for the sans family with \usepackage{helvet}.

share|improve this answer
    
You beat me by 30 seconds. +1. –  lockstep Nov 3 '10 at 23:30
    
great, thx, now how would i change the font family only for headlines? –  elementz Nov 3 '10 at 23:37
    
\usepackage{sectsty}\allsectionsfont{\sffamily} –  Martin Heller Nov 3 '10 at 23:54
    
@lockstep: Well, you beat me by 2 minutes on the \paragraph spacing question. (I still posted because we propose different approaches.) –  mpg Nov 4 '10 at 0:02

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.