punctuation marks have different fonts in and out of equations in xetex

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?

-
Check out the mathspec package, which allows you to set the maths text fonts. – Alan Munn Feb 4 '12 at 17:47
You could use mathastext or unicode-math for more comprehensive support. – rdhs Feb 4 '12 at 20:54

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 http://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}


-
This isn't a solution. Compare the commas in This, a sample sentence, with the comma in mod 3,. – rdhs Feb 4 '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 tex.stackexchange.com/questions/38711/… – Levon Haykazyan Feb 4 '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 4 '12 at 20:17