I am playing around with different math fonts, and currently I am using:
\usepackage[amsthm, libertine, varbb]{newtxmath} which gives me some nice fonts for math, \mathcal, \mathbb and \mathscr. The only thing I don't like is the result of \mathfrak. I think I found some nice font files online, let's call it MyFrakFont.otf, but I couldn't figure out how to load this font. I am using babel and fontspec, none of which seems capable of loading the font for \mathfrak (I guess these packages don't deal with math fonts), so I am stuck. How can I use a custom font file for the \mathfrak command?
- 715
2 Answers
Define a font face and redefine \mathfrak to use the font by means of \text.
Replace Lucida Blackletter OT, used just by way of example, with your preferred Fraktur font.
\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage[amsthm, libertine, varbb]{newtxmath}
\setmainfont{Libertinus Serif}
\newfontface{\preferredfraktur}{Lucida Blackletter OT}[Scale=MatchUppercase]
\AtBeginDocument{%
\RenewDocumentCommand{\mathfrak}{m}{\text{\normalfont\preferredfraktur#1}}%
}
\begin{document}
$a+\mathcal{B}+\mathbb{C}+\mathscr{D}+\mathfrak{x}+\mathfrak{Z}$
\end{document}
- 1,121,712
You can use OpenType fonts with unicode-math, although you’ll need to replace \usepackage[libertine]{newtxmath} with an OpenType math font, such as Libertinus Math:
\documentclass{article}
\usepackage{amsmath, amsthm}
\usepackage{unicode-math}
\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}
% Unifraktur Maguntia is available at https://unifraktur.sourceforge.net/maguntia.html#comparison
% Stylistic Set 1 has the modern forms.
\setmathfont{Unifraktur Maguntia}[range=frak, StylisticSet=1, Scale=MatchUppercase]
\setmathfont{Euler Math}[range={cal, bfcal}, Scale=MatchUppercase]
\begin{document}
$a+\mathcal{B}+\mathbb{C}+\mathscr{D}+\mathfrak{x}+\mathfrak{Z}$
\end{document}
Since Unicode only defines one script alphabet, you’ll need to load an alphabet with range=cal or range=scr to get both \mathcal and \mathscr.
- 44,045

