1

I know there are multiple questions about bold sans serif math, namely this and this and this. However, all those questions' OP seem to be satisfied with upright math, which I'm not. I tried to play around myself. My goal is to have a math version sansbold to use in headings (the font lmodern and bold sans headings are prescribed). For completeness, I also tried a sans mathversion, which I won't need, though.

My following code was obtained by copying and modifying those parts of sansmath.sty that I understood:

\documentclass{scrartcl}
\usepackage{lmodern}
\usepackage[T1]{fontenc}

\DeclareMathVersion{sansbold}
\SetSymbolFont{operators}{sansbold}{OT1}{lmss}{bx}{n}
\SetSymbolFont{letters}{sansbold}{OML}{cmssm}{b}{it} % for cmmi/lmmi
\SetSymbolFont{symbols}{sansbold}{OMS}{cmsssy}{b}{n} % for cmsy/lmsy
%\SetSymbolFont{symbols}{sansbold}{OMS}{lmsy}{b}{n} % actual lmsy
\SetSymbolFont{largesymbols}{sansbold}{OMX}{cmssex}{m}{n} % for cmex/lmex
\SetMathAlphabet\mathsf{sansbold}{OT1}{lmss}{bx}{n}
\SetMathAlphabet\mathbf{sansbold}{OT1}{lmss}{bx}{n}

\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{lmss}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{cmssm}{m}{it} % for cmmi/lmmi
\SetSymbolFont{symbols}{sans}{OMS}{cmsssy}{m}{n} % for cmsy/lmsy
%\SetSymbolFont{symbols}{sans}{OMS}{lmsy}{m}{n} % actual lmsy
\SetSymbolFont{largesymbols}{sans}{OMX}{cmssex}{m}{n} % for cmex/lmex
\SetMathAlphabet\mathrm{sans}{OT1}{lmss}{m}{n}
\SetMathAlphabet\mathrm{sans}{OT1}{lmss}{bx}{n}

\usepackage{amssymb}

\SetMathAlphabet{\mathfrak}{sansbold}{U}{euf}{b}{n}
\SetMathAlphabet{\mathfrak}{sans}{U}{euf}{m}{n}

\newcommand{\test}{\(
    \nsubseteq 
    \mathsf{A} \mathfrak{A} \mathrm{A} \mathcal{A} \mathbf{A} a + b \not \leq \subseteq c \sum \oplus \bigoplus \int_a^b \sin \gamma \Gamma ( \bigl( \Bigl( \biggl(
\)}

\parindent=0pt
\begin{document}
    \section{Bla \mathversion{sansbold}\test}
    \mathversion{sans} 
    \test
    
     \mathversion{sansbold} 
    \test
    
    \mathversion{bold}
    \test
    
    \mathversion{normal}
    \test
\end{document}

Outcome:

enter image description here

There are some questions I have:

  1. deleted, makes no sense anymore.
  2. deleted, makes no sense anymore.
  3. What's wrong with \nsubseteq? IIRC this comes from amsfonts. Since the symbol in \mathversion{bold} is also not bold, I guess this is because amsfonts provides no bold?
  4. the documentation of sansmath says the package provides fonts ssmsam and ssmsbm corresponding to amsfonts. But setting \SetSymbolFont{AMSa}{sans}{U}{ssmsam}{m}{n} provides wrong symbols. To my surprise, even sansmath.sty contains the line \DeclareSymbolFont{AMSa}{U}{ssmsa}{m}{n}, which is, if I'm not mistaken, the amsfonts-font? How to use ssmasm/ssmsbm correctly?
  5. What's wrong with \sum, \int? I guess already lmodern provides no bold for those symbols. Am I correct in assuming that sansmath also does not? Setting \SetSymbolFont{largesymbols}{sansbold}{OMX}{cmssex}{b}{n} warns me that that font doesn't exist. So I assume yes.

And, most important:

  1. Am I doing something deeply wrong?

I see that symbols are missing, the largesymbols are kind of ugly, but all this is much prettier than \boldmath-serif math in section titles. Anyway, I don't have so much math in titles, obviously, so I can avoid using the missing symbols easily.

Edit. Sorry, my question is already so long. I still want to explicitly state my intend: I have to use lmodern as main font, and bold sans as the font for headings. I want to define a math version sansbold to fit in these requirements best possible. I thought, using fonts from the sansmath package could be handy. If I accidentally use cm-fonts and didn't notice, that's because cm and lm they are hard to tell apart in math. My idea was to use always use fonts from sansmath if provided (or, of course, lm if it does the job).

I have tried again to update my question so I actually use lm.

5
  • you loaded latin modern but used computer modern for all your additional fonts? Commented Nov 16, 2022 at 15:56
  • @DavidCarlisle I should have added: I really don't precisely know what I'm doing! But aren't the cms…-fonts I load from sansmath? There is no lmssm, for instance.
    – Bubaya
    Commented Nov 16, 2022 at 17:32
  • some are from sansmath yes, but my comment was that you were not using any latin modern math fonts, despite the title. Commented Nov 16, 2022 at 17:42
  • @DavidCarlisle Didn't notice, you're totally right! Updated.
    – Bubaya
    Commented Nov 16, 2022 at 18:04
  • I added a version to my answer (I'm not sure if you get an alert on edited answers?) Commented Nov 16, 2022 at 18:08

1 Answer 1

2

Your settings all seem a bit surprising given the post title asks about latin modern and you use computer modern for all the declarations. But to answer the questions.

  1. Why does \mathversion{sans} $\mathbf{A}$ choose the correct font,

    You do not define "correct" here. I would have expected one of two desired outputs.

    lm bold roman (if you interpret \mathrm and \mathbf as upright serif) or
    lm bold sans serif (if you interpret \mathrm and \mathbf as upright "main font family")

You actually get .\OT1/cmr/bx/n/10.95 A so cm bold which is the latex default as (as you comment) this alphabet has not been declared for this version

  1. Same for other alphabets commented out.

You get the same answer as 1 except for example \mathrm which by default uses the operators font, which you have declared.

  1. What's wrong with \nsubseteq?

As you say, the amsfonts are not available in bold (nor the derived versions in sansmath)

  1. the line \DeclareSymbolFont{AMSa}{U}{ssmsa}{m}{n}, which is, if I'm not mistaken, the amsfonts-font?

ussmsa.fdshows {U}{ssmsa} relates to the fonts ssmsam(10,7,5) which are not from the AMS

  1. What's wrong with \sum, \int?

You are using computer modern here not latin modern, you get \OMX/cmssex/m/n/14.4 P extension font from sansmath and as you say this, like the origial cm has no bold large symbol font

  1. Am I doing something deeply wrong?

Possibly, that depends if the actual requirement was to use Latin modern.

I guess you could add

\SetSymbolFont{AMSa}{sansbold}{U}{ssmsa}{m}{n}
\SetSymbolFont{AMSb}{sansbold}{U}{ssmsb}{m}{n}
\SetSymbolFont{AMSa}{sans}{U}{ssmsa}{m}{n}
\SetSymbolFont{AMSb}{sans}{U}{ssmsb}{m}{n}

so

enter image description here

\documentclass{scrartcl}
\usepackage{lmodern}
\usepackage[T1]{fontenc}

\DeclareMathVersion{sansbold}
\SetSymbolFont{operators}{sansbold}{OT1}{cmsmf}{bx}{n}
\SetSymbolFont{letters}{sansbold}{OML}{cmssm}{b}{it}
\SetSymbolFont{symbols}{sansbold}{OMS}{cmsssy}{b}{n}
\SetSymbolFont{largesymbols}{sansbold}{OMX}{cmssex}{m}{n}
\SetMathAlphabet\mathsf{sansbold}{OT1}{cmsmf}{bx}{n}
\SetMathAlphabet\mathbf{sansbold}{OT1}{cmsmf}{bx}{n}
\SetMathAlphabet\mathit{sansbold}{OT1}{cmsmf}{bx}{it}

\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{cmsmf}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{cmssm}{m}{it}
\SetSymbolFont{symbols}{sans}{OMS}{cmsssy}{m}{n}
\SetSymbolFont{largesymbols}{sans}{OMX}{cmssex}{m}{n}
\SetMathAlphabet\mathsf{sans}{OT1}{cmsmf}{m}{n}
\SetMathAlphabet\mathbf{sans}{OT1}{cmsmf}{bx}{n}
\SetMathAlphabet\mathit{sans}{OT1}{cmsmf}{m}{it}

\usepackage{amssymb}

\SetMathAlphabet{\mathfrak}{sansbold}{U}{euf}{b}{n}
\SetMathAlphabet{\mathfrak}{sans}{U}{euf}{m}{n}

\SetSymbolFont{AMSa}{sansbold}{U}{ssmsa}{m}{n}
\SetSymbolFont{AMSb}{sansbold}{U}{ssmsb}{m}{n}
\SetSymbolFont{AMSa}{sans}{U}{ssmsa}{m}{n}
\SetSymbolFont{AMSb}{sans}{U}{ssmsb}{m}{n}


\newcommand{\test}{\(
    \nsubseteq 
    \mathfrak{A} \mathrm{A} \mathcal{A} a + b \not\subseteq c \sum \oplus \bigoplus \int_a^b \sin \gamma \Gamma ( \bigl( \Bigl( \biggl(
\)}

\parindent=0pt
\begin{document}
    \section{Bla \mathversion{sansbold}\test}


\showoutput
\sbox0{\mathversion{sans} $\mathbf{A}$}%\showbox0

    \mathversion{sans} 
    \test
    
     \mathversion{sansbold} 
    \test
    
    \mathversion{bold}
    \test
    
    \mathversion{normal}
    \test
\end{document}
6
  • Ah, so neither AMSa/b nor the sans version provides bold, makes sense. And adding ssmsa/b makes just no difference because they look the same?
    – Bubaya
    Commented Nov 16, 2022 at 18:07
  • @Bubaya I assume some of the glyphs are different or they would not have made a font, I didn't do a side by side comparison. A lot of symbols will be the same, a sans serif + is a +. Commented Nov 16, 2022 at 18:10
  • Actually the + is different, as clearly visible in bold :). But a \mho, e.g., shows the difference. I guess boldface versions of the ams symbols or the extended (sans) symbols exists nowhere, correct?
    – Bubaya
    Commented Nov 16, 2022 at 18:13
  • @Bubaya the world is a big place, hard to say something doesn't exist. you might prefer to use luatex and an opentype math font where you can use fakebold Commented Nov 16, 2022 at 18:17
  • tex.stackexchange.com/a/601312/1090 Commented Nov 16, 2022 at 18:18

You must log in to answer this question.

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