5

I would like to set the math font as Garamond-Math (here) except that greek letters should come from a different font (for an illustration, computer modern in the example below.). But it seems declaring the new font does not work.

How to achieve this?

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}
\setmathfont{Garamond-Math.otf}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareSymbolFont{gs}{OML}{cmm}{m}{it}
\DeclareMathSymbol{\alpha}{\mathalpha}{gs}{11}
\DeclareMathSymbol{\beta}{\mathalpha}{gs}{12}
\DeclareMathSymbol{\gamma}{\mathalpha}{gs}{13}

\begin{document}
\[2a\alpha=\theta\]
\end{document}

2 Answers 2

4

unicode-math does many things \AtBeginDocument, you can delay your declarations:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Garamond-Math.otf}

\DeclareSymbolFont{gs}{OML}{cmm}{m}{it}
\newcommand*\RedeclareMathSymbol[4]{%
  \let#1\relax
  \DeclareMathSymbol{#1}{#2}{#3}{#4}%
}

\AtBeginDocument{%
  \RedeclareMathSymbol{\alpha}{\mathalpha}{gs}{11}%
  \RedeclareMathSymbol{\beta}{\mathalpha}{gs}{12}%
}

\begin{document}
\[2a\alpha=\beta\theta\]
\end{document}

mixing fonts

6

It doesn't work because unicode-math sets the font tables at begin document.

You should use the range feature instead:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}

\setmathfont{Garamond-Math.otf}
\setmathfont{latinmodern-math.otf}[
  Scale=MatchLowercase,
  range=it/{greek,Greek},
]
\setmathfont{Garamond-Math.otf}[range=\int]


\begin{document}

\[2a\alpha=\theta\]

\end{document}

enter image description here

2
  • +1 Thank you for this answer. Where can I learn more about the range feature? (E.g., if I wanted to land other groups of symbols in one font or the other.)
    – Alexis
    Nov 9, 2020 at 20:54
  • 1
    @Alexis The source is the manual of unicode-math
    – egreg
    Nov 9, 2020 at 20:56

You must log in to answer this question.

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