8

Inspired by Mr. Carlisle's answer here, I was wondering how to use a bold sans serif math font.

The way one can create normal bold sans serif text is as follows:

\documentclass[]{standalone}

\begin{document}
\textbf{\textsf{This text is bold.}}
\end{document}

How would I get bold sans serif math, though? I tried many combinations, such as:

\documentclass[]{standalone}

\begin{document}
\textbf{$\mathsf{x^2+2}$}
\end{document}

None of these seem to give bold sans serif math effect, though!

1
  • 3
    you can use \boldmath as I used in the referenced answer, or for a subterm inside a larger math expression, you can use \bm from the package of that name. Nov 20, 2016 at 15:08

3 Answers 3

7
\documentclass[]{standalone}
\usepackage{bm}
\begin{document}
{\boldmath $\mathsf{x^2+2}$}

$\bm{\mathsf{x^2+2}}$
\end{document}

enter image description here

8
  • This happens to be that one combination that I hadn't tried! Thanks again! Nov 20, 2016 at 15:34
  • Late to the party, but: using mathsf here has the obvious disadvantage of rendering all variables upright.
    – Bubaya
    Nov 15, 2022 at 3:40
  • @Bubaya sure but it is what the OP asked for. Nov 15, 2022 at 9:09
  • @DavidCarlisle I don’t interpret his question in a way that he intends to do upright letters. He only asks for sans boldface. What he tries with mathsf has upright letters, true, but I think that’s not his goal, and, besides, it looks questionable.
    – Bubaya
    Nov 15, 2022 at 13:39
  • 1
    @Bubaya well the OP ticked the answer so (s)he says that this was the requirement. Who are we to disagree? Sans serif math is only used in special (or very elementary) settings and it is not at all implausble that upright is required. slanted bold sans serif is of course possible but more fidly to set up as it is not provided by default, and no need for a complicated answer if not required. Note the other answers, using unicode-math (where slanted and upright both provided by defaut) interpreted the question as asking for uprght. Nov 15, 2022 at 15:34
2

To extend the answer into the unicode space, the unicode-math package (using fontspec in the background) allows mapping one (or more) ranges of alphabet symbols, say italic and upright, to another range, say bold sans upright, with the range option. The 17 ranges (up, it, frak, tt, cal, etc) can be restricted to lower/upper/Latin/Greek or numbers, as well.

For specific (grouped) symbols, the various \sym..{} commands, like \symbf{} for bold face, perform a similar function.

unicode-math mapping to bold

Key to the illustration: Italic (magenta); italic mapped to bold sans upright (red); both italic and upright mapped to bfsfup; upright version of \sym..{} command; the \symbfsfup command.

\documentclass[12pt]{standalone}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[Colour=blue]
%\setmathfont{Asana Math}[range={it},Colour=magenta]
\setmathfont{Asana Math}[range={it->bfsfup,up->bfsfup},Colour=red]
\setmainfont{Noto Serif}
\begin{document}
\begin{tabular}{rl}
\verb|range={it->bfsfup,up->bfsfup}| & $AB ab \Phi \Mu \Lambda \phi \mu \lambda 123$ \\
\end{tabular}
\end{document}
2

As of 2020, unicode-math provides the alphabets \symbfsfup, \symbfsfit, \mathbfsfup and \mathbfsfit.

If you are using PDFLaTeX, the isomath package provides \mathsfbfit.

You might choose to declare a sansbold math version, perhaps for math expressions in bold sans-serif headers. In unicode-math, there is no bold sans-serif math font defined, but you might fake one with FakeBold.

\documentclass{article}
\usepackage{unicode-math}

\pagestyle{empty}

\defaultfontfeatures{ Scale = MatchLowercase, Ligatures = TeX }
\setmathfont{Latin Modern Math}
\setmathfont[ version=sansbold,
              FakeBold = 1.2
            ]{Fira Math}
            
\newcommand\sansboldmath{\mathversion{sansbold}}

\begin{document}

\section{\sffamily\bfseries\upshape\sansboldmath
         Proving \( \symup{e}^{\symup{i} \uppi} + 1 = 0 \) }

\end{document}

Sans Bold Math sample

To do the equivalent in legacy NFSS, you would need to find sans-serif bold math fonts that match the encoding of your main math font. The newtxsf package might work with newtxmath or newpxmath.

You must log in to answer this question.

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