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.)

6 Answers 6

156

\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.).

13
  • 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 5, 2011 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, 2013 at 20:50
  • 13
    The command \usepackage{helvet} does not provide Helvetica font, but an Helvetica clone called Nimbus Sans L.
    – user34087
    Jul 24, 2013 at 8: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, 2013 at 21:46
  • 2
    @alfC haha. ok ;) I definitely sympathise with the idea that TeX/LaTeX is the opposite of newbie-friendly (user-friendly, even). Jun 4, 2014 at 4:25
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!

4
  • 2
    cmbright is nice but in what sense it's the best solution?
    – lhf
    Feb 18, 2021 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, 2021 at 22:29
  • 1
    it seems that this font is not vectorized correctly, zooming in shows that the font is very pixelated? tex.stackexchange.com/questions/2095/… Nov 23, 2021 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 2, 2022 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

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).

1
  • Thanks for calling me a hero, you’re too kind.
    – Gaussler
    Sep 9, 2022 at 11:17
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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .