Discussion:
[XeTeX] Unicode sans serif math
7***@gmx.ch
2017-12-02 17:43:26 UTC
Permalink
Hi All,
I would typeset a document containig unicode mathematic characters
and sans serif fonts. It seems that this is almost impossible
since the fonts used to typeset the variables in math mode use always
a serif font.

Do you have an idea if it is possible to type a document only with sans serif
fonts. I have read quite carefully the documentation
for the "fontspec" and "unicodemath" package without finding
any clear direction on how to achieve that. Should I define new math alphabet?


My example is with the "DejaVu Sans" font but the problem should
be more or less the same if the "lucida sans" font would have been choosen.

Sans serif math is useful for presentation (the beamer class) and sometimes
for printed document too.

Thanks for your help,

Alan

Here is an example to show the problem: the variable "F" and subscript "n"
are in serif font.

-------------------------------Example--------------------------------------
\documentclass{article}

\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}

\setmathfont{texgyredejavu-math.otf}
\setmainfont{DejaVuSans}[
Extension=.ttf,
UprightFont=*,
ItalicFont=*-Oblique,
BoldFont=*-Bold,
BoldItalicFont=*-BoldOblique,
]
\setsansfont{DejaVuSans}[
Extension=.ttf,
UprightFont=*,
ItalicFont=*-Oblique,
BoldFont=*-Bold,
BoldItalicFont=*-BoldOblique,
]
\setmonofont{DejaVuSansMono}[% main typewriter
Extension=.ttf,
UprightFont=*,
ItalicFont=*-Oblique,
BoldFont=*-Bold,
BoldItalicFont=*-BoldOblique,
]


\begin{document}

\section{Number $\mathbf{φ}$ properties}
This is one interessant property:
\begin{equation}
φ^2=φ+1
\end{equation}

and an other one (related to Fibonacci numbers)

\begin{equation}
\lim_{n→∞} \dfrac{F_{n+1}}{F_n}=φ
\end{equation}

\end{document}


--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/list
7***@gmx.ch
2017-12-04 09:35:04 UTC
Permalink
Hi All,
Finally I have found a solution even if I don't know if
it is fully correct.

The following document can be typeset with the sans serif font «DejaVuSans»
(when xelatex is used) or with the similar font «arev» (when pdftex is used).

The mathematical part is correctly set in sans serif font
and even a greek text (for an Euclid
citation for instance) would be correctly typeset if the font «DejaVuSans»
is used.

Alan

--------------------------MathSanserif.tex-------------------------------
\documentclass{article}

\usepackage{iftex}
\usepackage{amsmath}

\ifXeTeX
\usepackage{fontspec}
\usepackage{unicode-math}
%DejaVuSans
%\setmathfont{texgyredejavu-math.otf}
\setmathfont{LucidaBrightMathOT.otf} %Font color match better with dejaVuSans
\setmathfont{DejaVuSans.ttf}[range=up]
\setmathfont{DejaVuSans.ttf}[range=bb->bfsfup]
\setmathfont{DejaVuSans-Oblique.ttf}[range=it]
\setmathfont{DejaVuSansMono.ttf}[range=tt]
\setmathfont{DejaVuSans-Bold.ttf}[range=bfup]
\setmathfont{DejaVuSans-BoldOblique.ttf}[range=bfit]
\setmainfont{DejaVuSerif}[
Extension=.ttf,
UprightFont=*,
ItalicFont=*-Italic,
BoldFont=*-Bold,
BoldItalicFont=*-BoldItalic,
]
\setsansfont{DejaVuSans}[
Extension=.ttf,
UprightFont=*,
ItalicFont=*-Oblique,
BoldFont=*-Bold,
BoldItalicFont=*-BoldOblique,
]
\setmonofont{DejaVuSansMono}[% main typewriter
Extension=.ttf,
UprightFont=*,
ItalicFont=*-Oblique,
BoldFont=*-Bold,
BoldItalicFont=*-BoldOblique,
]
\renewcommand\familydefault{\sfdefault}
\else
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}%
\newcommand\pointcentre{\ifmmode\cdot{}\else\textperiodcentered{}\fi}
\RequirePackage{newunicodechar}
\newunicodechar{×}{\ensuremath{\times}}
\newunicodechar{Φ}{\ensuremath{\Phi}}
\newunicodechar{φ}{\ensuremath{\phi}}
\newunicodechar{Δ}{\ensuremath{\Delta}}
\newunicodechar{α}{\ensuremath{\alpha}}
\newunicodechar{±}{\ensuremath{\pm}}
\newunicodechar{∞}{\ensuremath{\infty}}
\newunicodechar{≠}{\ensuremath{\neq}}
\newunicodechar{∀}{\ensuremath{\forall}}
\newunicodechar{→}{\ensuremath{\rightarrow}}
\newunicodechar{·}{\pointcentre}
\newunicodechar{⇔}{\ensuremath{\Leftrightarrow}}
\newunicodechar{ℤ}{\ensuremath{\mathbb{Z}}}
\newunicodechar{∈}{\ensuremath{\in}}
\usepackage{arev}
\fi


\begin{document}

\section{Number $\mathbf{φ}$ properties}
This is one interessant property:
\begin{equation}
φ^2=φ+1
\end{equation}

and an other one (related to Fibonacci numbers)

\begin{equation}
\lim_{n→∞} \dfrac{F_{n+1}}{F_n}=φ
\end{equation}

Finally the last property $\frac{1}{φ}=φ-1$ to have a formula inline.
\end{document}


--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/listinfo/xetex

Loading...