Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
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

1 Answer 1

up vote 2 down vote accepted

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}

output of code

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.