2

I know how to get sans-serif math for the whole document—that is easy. My question is how do I get sans-serif math only when I am in a sans-serif mode? I would like the math font to be serif normally, but change to sans serif when I use sans-serif mode, such as using \textsf or something else.

In my case, I am using tufte-latex's sfsidenotes option, which puts all the typesets all the side notes in the document in the sans-serif style.

Consider this MWE:

\documentclass[nobib, sfsidenotes]{tufte-handout}
\renewcommand{\sfdefault}{cmbr}

\begin{document}

Let \(f\) be a continuous\sidenote{Moreover, this can be true when \(f\) is bounded on \(R\), \(f\) is discontinuous on only finitely many smooth curves, and the iterated integrals exist.} function on the rectangular region \(R = \{ (x, y) \mid a \leq x \leq b, c \leq y \leq d\}\). Then \[ \iint_R dA f(x, y) = \int_a^b dx \int_c^d dy f(x, y) = \int_c^d dy \int_a^b dx f(x, y).\]

The side notes that results is: Image

Notice that the f and the R are in the default serif font, which I find ugly.

2
  • 2
    Please add \end{document} so this will compile. Maybe define a sans maths 'version'? If the main place you need this is side notes, you could probably use that to automatically switch. (But the tufte classes do things in somewhat non-standard ways and I'm not that familiar with them.) Which engine are you using?
    – cfr
    Commented Jul 13 at 17:39
  • Hopefully you know this, but be aware that this is very nonstandard in mathematical writing (in all fields/conventions I know) — usually if multiple font variants are used for mathematical variables within a document, it’s to distinguish different types of objects (eg vectors and scalars). Using serif and sans for the same objects, just depending on the surrounding text, would be very distracting for me and I think for most readers familiar with the standard convention. Commented Jul 14 at 22:11

1 Answer 1

4

You want to declare a sans-serif math version, similar to \mathversion{bold} and \boldmath. Here is a MWE declaring sans (and bold sans) math versions in LuaLaTeX/XeLaTeX:

\documentclass{article}
\usepackage[paperwidth=10cm]{geometry} % Formatting for a MWE on TeX.SX
\usepackage{unicode-math}
\usepackage{microtype}

\defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
\setmainfont{KpRoman}
\setsansfont{KpSans}
\setmonofont{KpMono}
\setmathfont{KpMath-Regular.otf}
\setmathfont{KpMath-Bold.otf}[version=bold]
\setmathfont{KpMath-Sans.otf}[version=sans]
\setmathfont{KpMath-Sansbold.otf}[version=boldsans]

\newcommand\sansmath{\mathversion{sans}}
\newcommand\boldsansmath{\mathversion{boldsans}}

\begin{document}

\section*{\sffamily\bfseries\boldsansmath Integration on Rectangular Regions of 
\(\mathbb{R}^2\)}


Let \(f\) be a continuous function on the rectangular region \(R = \{ (x, y) \mid a \leq x \leq b, c \leq y \leq d\}\). Then
\begin{align*}
&\iint_R dA f(x, y) \\
= &\int_a^b dx \int_c^d dy f(x, y) \\
= &\int_c^d dy \int_a^b dx f(x, y)
\end{align*}

\sffamily\sansmath
Moreover, this can be true when \(f\) is bounded on \(R\), \(f\) is discontinuous on only finitely many smooth curves, and the iterated integrals exist.

\end{document}

KP-fonts sample

You could substitute any other OpenType Math fonts,. If you intend to use this often, you probably want to define an environment that sets \sffamily\sansmath, or add these to the definitions of high-level commands such as \sidenote.

For PDFLaTeX, the exact commands would depend on which legacy sans-serif math font you use, but here is a MWE to set up the fonts from sansmathfonts in \mathversion{sans}:

\documentclass{article}
\usepackage{amsmath}
\usepackage[paperwidth=10cm]{geometry} % Formatting for a MWE on TeX.SX

\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{xcmss}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{cmssm}{m}{it}
\SetSymbolFont{symbols}{sans}{OMS}{cmsssy}{m}{n}
\SetSymbolFont{largesymbols}{sans}{OMX}{cmssex}{m}{n}

\DeclareMathVersion{sansbold}
\SetSymbolFont{operators}{sansbold}{OT1}{xcmss}{bx}{n}
\SetSymbolFont{letters}{sansbold}{OML}{cmssm}{bx}{it}
\SetSymbolFont{symbols}{sansbold}{OMS}{cmsssy}{m}{n} % No bold symbols for this font.
\SetSymbolFont{largesymbols}{sansbold}{OMX}{cmssex}{m}{n} % No bold symbols for this font.

\newcommand\sansmath{\mathversion{sans}}
\newcommand\sansboldmath{\mathversion{sansbold}}

\begin{document}

\section*{\sffamily\bfseries\sansboldmath Integration on a Rectangular Region \(R\)}


Let \(f\) be a continuous function on the rectangular region \(R = \{ (x, y) \mid a \leq x \leq b, c \leq y \leq d\}\). Then
\begin{align*}
&\iint_R dA f(x, y) \\
= &\int_a^b dx \int_c^d dy f(x, y) \\
= &\int_c^d dy \int_a^b dx f(x, y)
\end{align*}

\sffamily\sansmath
Moreover, this can be true when \(f\) is bounded on \(R\), \(f\) is discontinuous on only finitely many smooth curves, and the iterated integrals exist.

\end{document}

Sansmathfonts sample

You must log in to answer this question.

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