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}
3
  • If your font hasn't the symbols, how can you get them from it? Please, be more specific with a MWE.
    – egreg
    Jan 5, 2015 at 22:54
  • @egreg The font has the symbols (= ∪ ∩ ∂ ⊂ ∞ ( ) [ ] etc.), but doesn't they don't get used. I tried the mathspec manual, where I found the quote, so I decided to ask here. I've updated the question with a MWE.
    – Earthliŋ
    Jan 5, 2015 at 23:28

2 Answers 2

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

6
  • 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 3, 2016 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 3, 2016 at 17:51
  • Is it possible to do the same for protected characters, like ~ or {?
    – Earthliŋ
    Mar 3, 2016 at 20:13
  • @Earthliŋ No. Use \sim and \{
    – egreg
    Mar 3, 2016 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 3, 2016 at 20:40
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.

You must log in to answer this question.

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