8

From the mathspec documentation

4.2 Symbols

There is currently no way to set the font for general mathematical symbols such as:

=, ×, ↦, ∂, ∅, ∈, ∫, ⊂

I'm using XeLaTeX for better font support. What can I do to get these symbols from my font?

In particular, I'm interested in (, ) and =.

(Before using XeLaTeX, I used the mathastext package with LaTeX.)

\documentclass[a4paper,twoside,12pt]{article}
\usepackage{mathspec}
\setmainfont[Ligatures=TeX]{Linux Libertine O}
\setmathsfont(Digits,Latin)[Uppercase=Regular,Lowercase=Regular]{Linux Biolinum O}
\setmathsfont(Greek)[Uppercase=Regular,Lowercase=Regular]{Linux Biolinum O}
\setmathrm{Linux Biolinum O}

\begin{document}
$\partial$ doesn't use the partial from Biolinum.

$∂$ doesn't typeset anything.
\end{document}
Earthliŋ
  • 1,140

2 Answers2

5
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\setmathfont[range="21A6]{latinmodern-math.otf}%  ↦  from LM math
\begin{document}
$=, ×, ↦, ∂, ∅, ∈, ∫, ⊂$
\end{document}

unicode-math has more features. See the documentation of unicode-math how single charachters can be used from another font.

5

It's not impossible when you have established a math font which has the symbols you need. It's just time consuming.

\documentclass[a4paper,twoside,12pt]{article}
\usepackage{amsmath}
\usepackage{mathspec}
\setmainfont[Ligatures=TeX]{Linux Libertine O}
\setsansfont[Ligatures=TeX]{Linux Biolinum O}
\setmathsfont(Digits,Latin)[Uppercase=Regular,Lowercase=Regular]{Linux Biolinum O}
\setmathsfont(Greek)[Uppercase=Regular,Lowercase=Regular]{Linux Biolinum O}
\setmathrm{Linux Biolinum O}

% "0 ordinary; "1 operator; "2 relation, "3 binary operation
\Umathcode`=="2 \csname symLatin:m:n\endcsname `=
\Umathcode`×="3 \csname symLatin:m:n\endcsname `× \def\times{×}
\Umathcode`↦="3 \csname symLatin:m:n\endcsname `↦ \def\mapsto{↦}
\Umathcode`∂="0 \csname symLatin:m:n\endcsname `∂ \def\partial{∂}
\Umathcode`∅="0 \csname symLatin:m:n\endcsname `∅ \def\emptyset{∅}
\Umathcode`∈="2 \csname symLatin:m:n\endcsname `∈ \def\in{∈}
\Umathcode`∫="1 \csname symLatin:m:n\endcsname `∫ \def\intop{∫}
\Umathcode`⊂="2 \csname symLatin:m:n\endcsname `⊂ \def\subset{⊂}

\begin{document}
$\partial$ uses the partial from Biolinum.

$∂$ does the same

\textsf{∂} is the proof

$a×b↦∂c∈d⊂∅$

$∫_a^b f(x)\,dx$
\end{document}

enter image description here

egreg
  • 1,121,712
  • This works great. However, the options "0 ordinary etc. don't work for a comma. \Umathcode',="0 \csname symLatin:m:n\endcsname ', (I replaced ` with ' to render it as code) leaves no space after the comma. (The other options leave spaces on both sides.) – Earthliŋ Mar 03 '16 at 16:51
  • 1
    @Earthliŋ For the comma it should be \Umathcode`,="6 \csname symLatin:m:n\endcsname `, The class for punctuation is 6. – egreg Mar 03 '16 at 17:51
  • Is it possible to do the same for protected characters, like ~ or {? – Earthliŋ Mar 03 '16 at 20:13
  • @Earthliŋ No. Use \sim and \{ – egreg Mar 03 '16 at 20:33
  • I meant that I want to use the ~ from my font. (At the moment it uses the general math font and not the character from the font, in the example Linux Biolinum O.) – Earthliŋ Mar 03 '16 at 20:40
  • @Earthliŋ I'd try \Umathchardef\sim="3 \csname symLatin:m:n\endcsname `~ – egreg Mar 03 '16 at 20:42