2

I'm using STIX2 Math with unicode-math but don't like the sans serif Bbb. I have managed to set blackboard bold characters to DejaVu with \setmathfont[range=bb]{DejaVu Math TeX Gyre} but this works only with \mathbb and I'm used to working with the \Bbb1, \BbbR, etc. commands that come with the unicode-math package.

I'm wondering if there's any way to change the font for these characters. I know I could list each one of them individually in the range but there must be a more straightforward way (I hope!).

\documentclass{article}

\usepackage{unicode-math}
\setmathfont{STIX Two Math}
\setmathfont[range=bb]{DejaVu Math TeX Gyre}

\begin{document}

\[
    \BbbR \mathbb{R}
\]

\end{document

I'd like these two to look the same.

2 Answers 2

1
\setmathfont{texgyredejavu-math.otf}[range={"1D538-"1D56B,"0211D}]

enter image description here

1
  • That's better than my answer, I'll delete (you might want to add the other ones in the 21xx range as they arethe most used, NQCPRZ Sep 7, 2021 at 8:33
0

I guess this is a part where unicode-math might benefit from a reworking.

What happens is that the package inputs unicode-math-table.tex which has the definition for all math symbols; for instance it has

\UnicodeMathSymbol{"0211D}{\BbbR}{\mathalpha}{/bbb r, open face r}%

which basically does

\Umathcode    "0211D = "7 "0 "211D
\Umathchardef \BbbR  = "7 "0 "211D

so typing \mathbb{R} will do the expected thing, because it produces \BbbR, but in a context where the math group might be different from 0 and indeed it is when a font with range=bb has been specified.

In my opinion, unicode-math-table should also record what range a character is assigned to, in order to be able to pair up the range and the corresponding math group so as to make the above definitions to have the correct default math group. Well, it does, but in a different place and does not go the whole way.

Alas! This is not possible at the moment. You can however get your \BbbX commands to work by redefining them at the right spot:

\documentclass{article}

\usepackage{unicode-math}

\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\setmathfont{TeX Gyre DejaVu Math}[
  Scale=MatchUppercase,
  range=bb,
]
\setmathfont{STIX Two Math}[range=] % to reset the font parameters

\ExplSyntaxOn
\cs_new_protected:Nn \__noble_reset_bb:
 {
  \int_step_inline:nnn { `A } { `Z }
   {
    \cs_set_protected:cpx { Bbb \char_generate:nn { ##1 } { 11 } }
     {
      \exp_not:N \mathbb { \char_generate:nn { ##1 } { 11 } }
     }
   }
 }
\AtBeginDocument{\__noble_reset_bb:}
\ExplSyntaxOff

\begin{document}

\[
    X \BbbR \mathbb{R} ℝ Y
\]

\end{document}

The example however shows that direct input of the Unicode character will not work.

enter image description here

For that a different approach has to be taken.

You must log in to answer this question.

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