321

How do you change the font for the whole document to sans-serif (or anything else)?

sophros
  • 8,714
  • 5
  • 30
  • 57
nickf
  • 499,078
  • 194
  • 614
  • 709

4 Answers4

222

I found the solution thanks to the link in Vincent's answer.

 \renewcommand{\familydefault}{\sfdefault}

This changes the default font family to sans-serif.

Huliax
  • 1,341
  • 1
  • 13
  • 25
nickf
  • 499,078
  • 194
  • 614
  • 709
  • 1
    The font used is Helvetica as explained in http://www.stat.berkeley.edu/~paciorek/computingTips/Basic_font_guidance_Latex.html – nalply Jul 09 '13 at 10:15
  • 7
    @nalply On my system it is Computer Modern Sans, most definitely not Helvetica (which is not available for free by the way). The source you cite is wrong. – Midgard May 25 '16 at 12:28
  • 7
    What if you want a specific font, not a random font from the family? – aquirdturtle Oct 11 '18 at 00:21
  • 2
    Other options apart from `sfdefault` are `rmdefault` (serif) and `ttdefault` (monospaced), according to [this](https://en.wikibooks.org/wiki/LaTeX/Fonts). – Matthias Braun Aug 23 '20 at 18:22
92

For a different approach, I would suggest using the XeTeX or LuaTex system. They allow you to access system fonts (TrueType, OpenType, etc) and set font features. In a typical LaTeX document, you just need to include this in your headers:

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setmainfont{Times}
\setmonofont{Lucida Sans Typewriter}

It's the fontspec package that allows for \setmainfont and \setmonofont. The ability to choose a multitude of font features is beyond my expertise, but I would suggest looking up some examples and seeing if this would suit your needs.

Just don't forget to replace your favorite latex compiler by the appropriate one (xelatex or lualatex).

Simon C.
  • 718
  • 7
  • 29
fideli
  • 2,772
  • 1
  • 20
  • 24
45

As second says, most of the "design" decisions made for TeX documents are backed up by well researched usability studies, so changing them should be undertaken with care. It is, however, relatively common to replace Computer Modern with Times (also a serif face).

Try \usepackage{times}.

dmckee --- ex-moderator kitten
  • 90,531
  • 23
  • 129
  • 225
  • 9
    What exactly does "well researched usability studies" mean? Do you just mean well thought out? I can't imagine there exist peer reviewed studies of the specific LaTeX defaults in academic journals. – Praxeolitic Jun 07 '14 at 10:20
  • 1
    @Praxeolitic You would ask me that *after* I moved away from the office that kept copies of both the [TeXbook](http://www.amazon.com/TeXbook-Donald-Knuth/dp/0201134489) and Lamport's [LaTeX: A Document Preparation System](http://www.amazon.com/LaTeX-Document-Preparation-System-Edition/dp/0201529831/ref=pd_sim_b_1?ie=UTF8&refRID=0645B49SHQJGXJYFZVYD) lying around. I think it is in Lamport, but I can't swear to it. – dmckee --- ex-moderator kitten Jun 07 '14 at 14:57
  • "Most". The default font is too hard to read, I prefer something lighter with less complexity in letter glyphs – Xeverous Feb 04 '18 at 21:52
  • 2
    Have to say, I think the default Computer Modern font looks hideous. (With apologies to Donald Knuth.) Your mileage may vary. – Leon Avery Jun 24 '19 at 17:12
  • I find serif font quite a bad choice for reading. in fact, there are probably the same studies showing the opposite regarding fonts. The serifs aren't very well prepared for reading. IMHO. – Minsky Jan 22 '21 at 14:02
34

This article might be helpful with changing fonts.

From the article:

The commands to change font attributes are illustrated by the following example:

  \fontencoding{T1}
  \fontfamily{garamond}
  \fontseries{m}
  \fontshape{it}
  \fontsize{12}{15}
  \selectfont

This series of commands set the current font to medium weight italic garamond 12pt type with 15pt leading in the T1 encoding scheme, and the \selectfont command causes LaTeX to look in its mapping scheme for a metric corresponding to these attributes.

Casey Jones
  • 123
  • 8
Vincent Ramdhanie
  • 98,815
  • 22
  • 134
  • 183