132

How do I typeset an entire document in sans-serif, e.g. Helvetica, without littering the document with font changes for every heading/paragraph, etc.? Like in How to set the font for a \section title (and chapter etc), but with the paragraphs all in sans-serif.

For example, I've seen documents typeset in Computer Modern and then switched to Palatino, but can I do the same with Helvetica with a few commands at the beginning?

(And please don't tell me to use a serif font for body copy / paragraphs. I know. I'm trying to use latex to typeset my resume to look like the one I've created in a word processor, which is hard to maintain but looks good. I'm hoping latex will let me do more advanced formatting/layout, separating content from form.)

Henri Menke
  • 109,596
Jared Updike
  • 1,493

6 Answers6

157

\renewcommand{\familydefault}{\sfdefault} will switch to using sans-serif for everything except mathematics. The sans-serif will be computer modern sans unless you also put \usepackage{helvet} in the preamble in order to set the default sans font to a clone of Helvetica (or \usepackage{avant} for Avant-Garde, etc.).

Paul Wintz
  • 402
  • 2
  • 14
Lev Bishop
  • 45,462
  • Is the font embedded in the resulting PDF? – Friendly Ghost Jul 05 '11 at 18:33
  • 4
    Usually yes, although it's possible that a particular distribution has been installed so that that isn't the default. For most standardly installed distributions, though, font embedding is enabled by default, AFAIK. – Alan Munn Jul 05 '11 at 18:40
  • 6
    @Lev, Is there a package that does this automatically?, that is, without the ugly \renewcommand{\familydefault}{\sfdefault} code. (Nothing against it, but this is the kind of code makes me embarrassed to explain to newcomers) – alfC Mar 22 '13 at 20:50
  • 13
    The command \usepackage{helvet} does not provide Helvetica font, but an Helvetica clone called Nimbus Sans L. –  Jul 24 '13 at 08:09
  • 3
    @alfC: some packages (eg: sourcesanspro, cabin) provide an option. The LaTeX Font Catalogue will show this in the code example for most (but not all) packages. – Silke Jul 24 '13 at 21:46
  • @Silex, thanks. Most Latex Font Catalogue examples I can find are a combination of a package and some "ugly" command. For example http://www.tug.dk/FontCatalogue/arial/ which reads \usepackage[scaled]{uarial} \renewcommand*\familydefault{\sfdefault} \usepackage[T1]{fontenc} – alfC Jul 24 '13 at 22:48
  • I changed the font style of my document to Helvetica using the commands written above \renewcommand{\familydefault}{\sfdefault} and \usepackage{helvet} in the preamble. Now I decided I actually don't like how it looks like. I erased the commands and compiled the document again, but it's giving me the same Helvetica font style. How can I change to the default LaTeX-font again? –  Sep 14 '13 at 17:40
  • @Rober Did you clean up your working files (delete the temporary build files) before you compiled again after those changes? – e-sushi Feb 14 '14 at 04:30
  • @alfC Is \usepackage{fixthefonts} so much less ugly than \renewcommand{\familydefault}{\sfdefault}? For newcomers I think it's good to just show them the default article style with lipsum and then insert/remove commands and see how the document changes. There's no getting around the "programming" (non-WYSIWYG) nature of LaTeX, in my opinion. They will have to want to edit a plain-text file of commands, or else they want LyX/something else. – isomorphismes Jun 04 '14 at 00:16
  • @isomorphismes, yes it is! Where can I find the package fixthefont? :) – alfC Jun 04 '14 at 04:09
  • 2
    @alfC haha. ok ;) I definitely sympathise with the idea that TeX/LaTeX is the opposite of newbie-friendly (user-friendly, even). – isomorphismes Jun 04 '14 at 04:25
  • This doesn't work with KOMA Script. – Druid Raves - V Feb 20 '18 at 14:39
  • @LevBishop How to change font-family for whole document including math mode? – Cyriac Antony Jun 06 '19 at 07:01
7

The best way to have BOTH the text AND the math is just by adding:

\usepackage{cmbright}

in the preambule of the LaTeX document. It gives a nice and homogenous look to your document. Cheers!

LeChat
  • 171
  • 2
    cmbright is nice but in what sense it's the best solution? – lhf Feb 18 '21 at 22:07
  • 1
    I believe it is, if you want both the text and the math to be without serif, which was the initial question :) – LeChat Feb 18 '21 at 22:29
  • 1
    it seems that this font is not vectorized correctly, zooming in shows that the font is very pixelated? https://tex.stackexchange.com/questions/2095/what-is-the-simplest-way-to-typeset-an-entire-document-in-sans-serif – Thomas Wagenaar Nov 23 '21 at 10:42
  • On my computer (another one from which I compiled the initial document I am checking cmbright on), I can zoom in 6400% with still no pixelation of the characters... To me, everything seems great so far. Have you tried another pdf viewer? – LeChat Mar 02 '22 at 14:32
6

In ConTeXt you obviously use \setupbodyfont. This will not affect math mode.

\setupbodyfont[ss]

\starttext

Sans-Serif

\stoptext

enter image description here

Henri Menke
  • 109,596
2

You can use the fontsetup package for easy configuration of fonts if you are willing to use XeLaTeX/LuaLaTeX. It supports two sans serif fonts Fira Sans and GFS Neohellenic, both with math support as of writing this answer.

\documentclass{article}

\usepackage[fira]{fontsetup} %\usepackage[gfsneohellenic]{fontsetup}

\begin{document} \section{Some section header.} The quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. 1234567890 \begin{align} \oint_{\gamma} \sum_{i=0}^n \int \bigcup \bigcap \ \symup{\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \omega \pi \rho \sigma \phi \psi \tau \omega}\ \alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \omega \pi \rho \sigma \phi \psi \tau \omega \ \partial \hbar \symbb{R, C, N, Z, Q} \end{align}

\end{document}

Fira: fira GFS Neohellenic: gfsneohellenic

There exists Lato Math, but not on CTAN, probably because it is not polished enough. Generated .otf file from GitHub: LatoMath.otf.

\documentclass{article}

\usepackage{unicode-math} \setmainfont{Lato} \setmathfont{LatoMath.otf}

\begin{document} \section{Some section header.} The quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. 1234567890 \begin{align} \oint_{\gamma} \sum_{i=0}^n \int \bigcup \bigcap \ \symup{\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \omega \pi \rho \sigma \phi \psi \tau \omega}\ \alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \omega \pi \rho \sigma \phi \psi \tau \omega \ \partial \hbar \symbb{R, C, N, Z, Q} \end{align}

\end{document}

lato

You can use the notomath package for sans serif text and math (on pdfLaTeX, LuaLaTeX and XeLaTeX). Noto math has open type support planned for the future as well.

\documentclass{article}

\usepackage[sfdefault]{notomath}

\begin{document} \section{Some section header.} The quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. 1234567890 \begin{align} \oint_{\gamma} \sum_{i=0}^n \int \bigcup \bigcap \ \alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \omega \pi \rho \sigma \phi \psi \tau \omega \ \partial \hbar \mathbb{R, C, N, Z, Q} \end{align}

\end{document}

notosans

I don't know how to make the summation and the integral signs sans serif in Noto.

1

In OpTeX, you can declare (for example):

\fontfam[heros]

Then the complete document is in sans serif (including Unicode-Math).

wipet
  • 74,238
1

Update: I now slightly prefer sansmathfonts over newtxsf. sansmathfonts seems to be missing some higher-level symbols like \leftrightarrow, but I noticed that newtxsf also replaces the font for numbers, making numbers in math mode look different from numbers in text, which I very much disliked and couldn't find a more specific fix for. What I use now is

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsthm}
\usepackage{sansmathfonts}
\renewcommand{\familydefault}{\sfdefault}

Original answer: No existing solution I found on SE or elsewhere worked for me, with the most common problem being pixelated math fonts. After testing many random packages and commands, I finally pieced together something that seems to work alright.

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsthm}
\usepackage{newtxsf}
\renewcommand{\familydefault}{\sfdefault}

This preamble gives me non-pixelated, sans-serif text and math. Note that the order can make a difference, for example it seems to be essential to load

\usepackage{amsmath,amsthm}

before

\usepackage{newtxsf}
MaxD
  • 1,137