5

How to set a font for math mode? I would like to have something like Segoe UI of something similar. Thank you

\documentclass{article}
\usepackage{fontspec}
\usepackage{firamath-otf}
\begin{document}
\begin{equation}
x+y=45
\end{equation}

\end{document}

Error:

enter image description here

Mico
  • 506,678

1 Answers1

7

If you want Segoe UI specifically, you can select all the symbols it contains with the range= option of \setmathfont, with another font such as Fira Math as your fallback for the rest.

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

\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Segoe UI}[
   Scale = 1.0,
   BoldFont = Segoe UI Semibold ,
   BoldItalicFont = Segoe UI Semibold Italic ]

\setmathfont{Fira Math}
\setmathfont{Segoe UI}[
  range= { up/{Latin,latin,Greek,greek,Digits},
           "2B-"2F,"3A-"3E,`¬,`·,`°,`±,`×,`÷,
           `←,`↑,`→,`↓,`↔,`↗,`↙,
           `Ω,`∂,`∆,`∏,`∑,`−,`∕,`∙,`∞,`∟,`∩,`∴,
           `∶,`≈,`≠,`≡,`≤,`≥,`⋲,
           `■,`□,`▪,`▫,`◊,`○,
           "02B0-"036F
         }]
\setmathfont{Segoe UI Semibold}[range=bfup/{Latin,latin,Greek,greek,Digits}]
\setmathfont{Segoe UI Italic}[range=it/{Latin,latin,Greek,greek}]
\setmathfont{Segoe UI Semibold Italic}[range=bfit/{Latin,latin,Greek,greek}]

\begin{document}

Segoe UI \textit{italic} \textbf{bold \textit{italic}} 0

\( \lim_{n \to 0} \frac{\partial}{\partial t}
    \int_n^\infty  \pm \symup{i} \sqrt{\symup{\pi} t} \symbfit{b} \times
                                 \symbfup{j} \,\mathup{d}t
    \approx \increment \symbfit{B} \)

\end{document}

Segoe UI font sample

You can tweak this further if you like. For example, you’d want to add "02B0-"036F, or at least \hat, to the range of all the math alphabets if you wanted to use the combining accent.

Davislor
  • 44,045