3

the following MWE

\documentclass{minimal}
\usepackage{mathspec}
\setmainfont{DejaVu Sans}
\setmathsfont(Digits,Latin,Greek){DejaVu Sans}
\setmathrm{DejaVu Sans}
\begin{document}
\(\mathrm{e}^{\mathrm{i}\pi}=-1\) = -1
\end{document}

typesets with xelatex into

enter image description here

How can I turn the = and - signs in math mode to DejaVu Sans ?

1

2 Answers 2

2

You can use “standard” declarations (note that in the formula I used the ASCII hyphen, outside it the minus sign U+2212).

\documentclass{article}
\usepackage{mathspec}
\setmainfont{DejaVu Sans}
\setmathsfont(Digits,Latin,Greek){DejaVu Sans}
\setmathrm{DejaVu Sans}

\makeatletter
\DeclareMathSymbol{=}{\mathrel}{\eu@DigitsArabic@symfont}{`=}
\DeclareMathSymbol{+}{\mathbin}{\eu@DigitsArabic@symfont}{`+}
\XeTeXDeclareMathSymbol{-}{\mathbin}{\eu@DigitsArabic@symfont}{"2212}
\makeatother

\begin{document}

\(\mathrm{e}^{\mathrm{i}\pi}=-1+1-1\) = −1+1−1

\end{document}

enter image description here

You can also add

\XeTeXDeclareMathSymbol{^^^^2212}{\mathbin}{\eu@DigitsArabic@symfont}{"2212}

for completeness.

More complete version (with also amsmath):

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathspec}
\setmainfont{DejaVu Sans}
\setmathsfont(Digits,Latin,Greek){DejaVu Sans}
\setmathrm{DejaVu Sans}

\makeatletter
\DeclareMathSymbol{=}{\mathrel}{\eu@DigitsArabic@symfont}{`=}
\DeclareMathSymbol{+}{\mathbin}{\eu@DigitsArabic@symfont}{`+}
\DeclareMathSymbol{.}{\mathord}{\eu@DigitsArabic@symfont}{`.}
\DeclareMathSymbol{\ldotp}{\mathpunct}{\eu@DigitsArabic@symfont}{`.}
\DeclareMathSymbol{;}{\mathpunct}{\eu@DigitsArabic@symfont}{`;}
\DeclareMathSymbol{,}{\mathpunct}{\eu@DigitsArabic@symfont}{`,}
\DeclareMathSymbol{\cdot}{\mathbin}{\eu@DigitsArabic@symfont}{"00B7}
\DeclareMathSymbol{\cdotp}{\mathpunct}{\eu@DigitsArabic@symfont}{"00B7}
\AtBeginDocument{%
  \XeTeXDeclareMathSymbol{-}{\mathbin}{\eu@DigitsArabic@symfont}{"2212}%
  \XeTeXDeclareMathSymbol{^^^^2212}{\mathbin}{\eu@DigitsArabic@symfont}{"2212}%
}
\makeatother

\begin{document}

\(\mathrm{e}^{\mathrm{i}\pi}=−1+1−1\) = −1+1−1

\(;.,\ldots\cdots\)

\(,\dots,\) \(a+\dots+z\)

\end{document}

enter image description here

1

You can use the following

\documentclass{minimal}
\usepackage{mathspec}
\setmainfont{DejaVu Sans}
\setmathsfont(Digits,Latin,Greek){DejaVu Sans}
\setmathrm{DejaVu Sans}
% 0 (large) \mathop, 1 (binary) \mathbin, 2 (vary) \mathbin, 3 (relation) \mathrel, 4 (opening) \mathopen, 5 (closing) \mathclose, 6 (punctuation) \mathpunct, 7 (alphabetic) \mathalpha
\Umathcode`=="3 \csname symLatin:m:n\endcsname `=
\Umathcode`-="2 \csname symLatin:m:n\endcsname `-
\Umathcode`×="2 \csname symLatin:m:n\endcsname `× \def\times{×}
\begin{document}
\(\mathrm{e}^{\mathrm{i}\pi}=-1\) = -1
\end{document}

giving

hyphen from font

as requested.

However, note that - is U+002D HYPHEN-MINUS and there is also U+2212 MINUS SIGN, which you might want to use instead:

minus sign from font

For this, replace the relevant line by

\Umathcode`-="2 \csname symLatin:m:n\endcsname `−

(last character in line being U+2212 MINUS SIGN).

I learned this from @egreg's answer to my question Symbols in XeLaTeX.

You must log in to answer this question.

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