18

The reigning answer for the Simplest way to typeset entire document in sans serif (Helvetica) completely disregards math-mode. This might be preferred when all math equations are set display style, but a matching font is a must for in-line equations.

My current MWE (based on the one given here) only gives the text-mode items in sans, but any math remains in serif style (in-line, numerical-only equations look particularly hideous).

How can I set math in sans-serif as well?

example

\documentclass[]{article}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[math]{blindtext}

\begin{document}

Text looks particularly bad when you have $123,400$ number-only equations in-line.

\blindmathpaper

\end{document}
3
  • Related/duplicate: How to typeset some text including math content in sans serif
    – Werner
    Commented Apr 28, 2014 at 16:44
  • @Werner And as prompted by the answer there, is there a way to do this without a package? Any equivalent of \renewcommand{\rmdefault}{phv} for math mode?
    – cslstr
    Commented Apr 28, 2014 at 16:46
  • @cslstr: No there is no one-liner to get sans serif math. Math is complicated, it involves a lot of fonts. Commented Apr 28, 2014 at 17:01

2 Answers 2

25

The answer, as I have pieced together, appears here on one page, for posterity.

The package sansmath ...

...is designed to offer sans-serif mathematics in the absence of proper sans maths fonts. After \usepackage{sansmath}, a new “math version” sans is defined, together with a command \sansmath, which behaves as \boldmath does. -from the documentation

So the MWE becomes:

\documentclass[]{article}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{sansmath} % Enables turning on sans-serif math mode, and using other environments
\sansmath % Enable sans-serif math for rest of document

\usepackage[math]{blindtext}

\begin{document}

Text looks particularly bad when you have $123,400$ number-only equations in-line.

\blindmathpaper

\end{document}

Which results in:

example sans math

2

You can use LuaLaTeX or XeLaTeX instead of LaTeX to compile your document,

and use FiraSans, Fira Math and FiraMono for sans serif text, math mode, and typewriter font, respectively (the font and its typesetting are so beautiful, they make my mouth water):

Fira fonts example

Here's the code:

\documentclass{article}

\usepackage[sfdefault]{FiraSans}        % Change default sans serif (sf) font to FiraSans
\usepackage[mathrm=sym]{unicode-math}   % Text in math mode will also be sans serif
\setmathfont{Fira Math}                 % Change default math font to FiraMath
\usepackage{FiraMono}                   % Change default typewriter (tt) font to FiraMono
\renewcommand\familydefault{\sfdefault} % Set sans serif font as default

\usepackage[english]{babel}             % For writing english in blindtext
\usepackage[math]{blindtext}            % Placeholder text

% Narrow page edges, so that we can have more text
\usepackage[a4paper, left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\pagestyle{empty}                       % Remove page numbers


\begin{document}

\blindmathpaper    % Placeholder text

\end{document}

Alternatively, if you insist on using LaTeX compiler, or have to use the helvet font:

Using arev, or arev with helvet is another solution (note that arev has some typesetting issues with subscripts, see this question for details).

arev + helvet

Code:

\documentclass{article}

\usepackage{arev}
\usepackage{helvet}
\renewcommand\familydefault{\sfdefault} % Set sans serif font as default

\usepackage[english]{babel}   % For writing english in blindtext
\usepackage[math]{blindtext}  % Placeholder text

% Narrow page edges, so that we can have more text
\usepackage[a4paper, left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\pagestyle{empty} % Remove page numbers


\begin{document}

\blindmathpaper  % Placeholder text

\end{document}
2
  • The package unicode-math doesn't seem to be compatible with the AMS packages or mathtools, which I use.
    – Someone
    Commented Jun 24, 2023 at 17:34
  • No, unicode-math isn't compatible with mathtools. But, for example, \coloneqq from mathtools is implemented as \coloneq in unicode-math.
    – Ooooscar
    Commented Jun 26, 2023 at 10:21

You must log in to answer this question.

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