5

I'm kinda new to the (Lua)LaTeX world but what I love especially about LuaTeX is the ability to include truetype system fonts in my document. For text fonts I find this easy, but for math fonts, I find it a real challenge.

I'm trying to use the Math & Technical math fonts in my document, I have the fonts installed on my system. These have names MathTechnicalP01 through P17, each family member having some glyphs. The character map is shown on the aforementioned site, but I'm struggling to make it work. I tried also with MathematicalPi fonts with no success. Can you please help me out?

Here is what I have tried so far:

\documentclass[12pt,a4paper]{article}    
\usepackage{amsmath}
\usepackage{fontspec,unicode-math}

\setmainfont{TeX Gyre Termes}    
\setmathfont[range=\mathup/{num}]{TeX Gyre Termes}  % for numbers
\setmathfont[range=\mathit]{MathTechnicalP12}       % for Greek
\setmathfont[range={"0023,"0041}]{MathTechnicalP09} % for \int, \sum ...

\begin{document}    

Main text here is times roman ...    
\[ x(t)=\int_{-B}^B X(f)e^{j2\pi ft} df \]
 % 
\[ \left(\frac{\mathrm{d}\phi}{\mathrm{d}\theta}\right)^{\top} \frac{\mathrm{d}\eta}{\mathrm{d}\mu} \quad \mathbf{R}^2 \sqrt{1/2\pi f} \]
 %
\[ \sum\int f(t)e^{j\omega t}dt{\rho\omega\pi}\mathcal{H} 2\pi\lambda \]
 %
\[ \sum\int a\otimes b \vec{c} - x + 2zp\gamma \]
 %
\begin{align*}
& \left(\dfrac{a}{2}\right)^2\cdot\pi+\left(\dfrac{b}{2}\right)^2\cdot\pi-\left(\dfrac{\sqrt{a^2+b^2}}{2}\right)^2\cdot\pi+ab &=ab\\
\Leftrightarrow & \dfrac{a^2}{4}\cdot\pi+\dfrac{b^2}{4}\cdot\pi-\dfrac{a^2+b^2}{4}\cdot\pi+ab &=ab\\
\Leftrightarrow & \dfrac{a^2}{4}\cdot\pi+\dfrac{b^2}{4}\cdot\pi-\left(\dfrac{a^2}{4}\cdot\pi+\dfrac{b^2}{4}\cdot\pi\right)+ab &=ab\\
\Leftrightarrow &  ab&=ab
\end{align*}

\end{document}

which outputs a bizarre of math:

enter image description here

3
  • 1
    with unicode-math the math font has to be an opentype math font (that is, one with a MATH table internally) so not TeX Gyre Termes but TeX Gyre Termes Math Mar 25, 2017 at 22:08
  • 1
    You need a math font as main math font as David already wrote. But beside this mixing it with other fonts with the range option doesn't always work. There are a number of open issues. Mar 25, 2017 at 22:11
  • @DavidCarlisle : Thanks for the reply, what do you mean by opentype math font, .otf? and how does this MATH table relate to the character map of the font published on the site? Ulrike, thank you for your comment, you mean these commercial fonts are not main math fonts and cannot be used in LuaLaTeX? Forgive my shallow knowledge in this regard.
    – Don
    Mar 25, 2017 at 22:30

1 Answer 1

4

Opentype fonts internally have lots of tables of data in addition to the actual characters (for ligatures, and character variants and...) in a (relatively) new addition to the opentype standard they can have a math table which gives all the information traditionally given in the font metrics for a TeX math font, how to size big delimiters, how to align fractions and square roots, how much to raise superscripts etc...

luatex (and xetex) essentially implement two math layout engines, one usin gtraditional Tex metrics and one using opentype. By default in latex the classic setting is used, but unicode-math switches things round to use the OpenType table method. but this means that the "main" font has to have this table.

Either way you can still use any text font for individual symbols or alphabets, just as in classic tex the main fonts in need to have a set of special math font parameters but any text font can be set as a math alphabet, for script or sans serif etc.

you can see if a font has such a table by looking in a font editor such as fontforge but easier is just check the description which will usually be something like "opentype math font".

So with unicode-math you need to pick one font that has a math table (eg, from memory: latin modern math, Cambria math, xits-math, stix2 math, any of the TeX Gyre Math fonts, Asana Math) Then you can look to add the other fonts for specific symbols or ranges.

Alternatively you may prefer to use the mathspec package, this takes the opposite approach to unicode-math and is designed to set up opentype text fonts for use in math (in xelatex, but it can't be that hard to extend to luatex, despite this answer of Will's that I just found after typing the above:-) LuaLaTeX and mathspec

You must log in to answer this question.

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