1

I am using xelatex to create a document in Armenian. I have the line

\setmainfont [Mapping=tex-text, Scale=MatchUppercase] {DejaVu Serif}

in my tex file to change the font to DejaVu Serif for the text. However the equations are still in Computer Modern. As a result punctuation marks, such as "," are different in and out of equation. This looks a bit ugly, because commas are very different in DejaVu Serif and Computer Modern. How can I fix this?

1 Answers1

2

The mathspec package allows you to set maths text fonts. Unfortunately this doesn't actually solve the punctuation problem. Code to do that was posted here: Punctuation marks in math mode in xetex/mathspec Here's an example.

% !TEX TS-program = XeLaTeX

\documentclass{article}
\usepackage{amsmath} % must be loaded before mathspec

\usepackage{mathspec}
\setmainfont [Mapping=tex-text, Scale=MatchUppercase] {DejaVu Serif}
\setmathsfont(Latin,Digits){DejaVu Serif}


% The following code is from https://tex.stackexchange.com/q/38711/2693
\makeatletter
\DeclareMathSymbol{,}{\mathpunct}{\eu@LatinLowercase@symfont}{`,}
\DeclareMathSymbol{.}{\mathord}{\eu@LatinLowercase@symfont}{`.}
\DeclareMathSymbol{<}{\mathrel}{\eu@LatinLowercase@symfont}{`<}
\DeclareMathSymbol{>}{\mathrel}{\eu@LatinLowercase@symfont}{`>}
\DeclareMathSymbol{/}{\mathord}{\eu@LatinLowercase@symfont}{`/}
\XeTeXDeclareMathSymbol{^^^^2026}{\mathinner}{\eu@LatinLowercase@symfont}{"2026}[\mathellipsis]
\makeatother


\begin{document}
This, a sample sentence, is some regular text.

\[
g(n) = 
\begin{cases}
\frac{2}{3}n & \text{if } n \equiv 0 \mod 3,\\
\frac{4}{3}n + \frac{1}{3} & \text{if } n \equiv 1 \mod 3,\\
\frac{4}{3}n - \frac{1}{3} & \text{if } n \equiv 2 \mod 3.
\end{cases}
\]
\end{document}

output of code

David Carlisle
  • 757,742
Alan Munn
  • 218,180
  • This isn't a solution. Compare the commas in This, a sample sentence, with the comma in mod 3,. – Chel Feb 04 '12 at 18:43
  • Thank you very much for the answer. Ironically, mathspec doesn't take care of punctuation symbols. For those I've used the answer to this question http://tex.stackexchange.com/questions/38711/punctuation-marks-in-math-mode-in-xetex-mathspec – Levon Haykazyan Feb 04 '12 at 18:46
  • @rdhs Oops. Thanks. I've modified my answer now incorporating question Levon linked to in his comment so that the answer is complete. – Alan Munn Feb 04 '12 at 20:17