# english number and ltr direction in xetex

I'm writing a document using xepersian and the text direction is right to left. Also I need to add formulas in the document. My problem is that all numbers in the formula are persian and if I add text in the formula it will be in the wrong order.

This is how I'm doing it:

\begin{align*}
Q_{n,0}&=1
Q_{n,k}&=Q_{n-1,k}+Q_{n-1,k-1}+\binom{n}{k}, \quad\text{for$n,k>$0.}
\end{align*}


In this example all 1's and 0's are persian and the text in the fromula is in the revers order. How do I fix it?

EDIT:

This is a sample doc that has the same problem:

\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}

\usepackage{xepersian}
\settextfont{XB Niloofar}
\setdigitfont{XB Niloofar}

\begin{document}
\begin{align*}
Q_{n,0}&=1
Q_{n,k}&=Q_{n-1,k}+Q_{n-1,k-1}+\binom{n}{k}, \quad\text{for$n,k>$0.}
\end{align*}

\end{document}

• Can you give a minimal working example (MWE)? – egreg Jun 16 '13 at 10:49
• I edited and added a sample code – soroosh.strife Jun 16 '13 at 10:58
• I don't know if this is what you mean, but \text keeps the main writing direction, which is right-to-left in your case; does \text{\LR{for $n,k>0$.} help? Also add \DefaultMathsDigits before \begin{document} if you want digits in math to be the Western ones. – egreg Jun 16 '13 at 11:04

\text uses the writing direction that was current when the formula in which it appears started. According to the documentation of xepersian you can use \lr. For getting digits in math mode using Western glyphs, issue the \DefaultMathsDigits command in the preamble.

Here's the minimal example (I commented the font selection lines because I don't have that font):

\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}

\usepackage{xepersian}
%\settextfont{XB Niloofar}
%\setdigitfont{XB Niloofar}
\DefaultMathsDigits

\begin{document}
\begin{align*}
Q_{n,0}&=1
Q_{n,k}&=Q_{n-1,k}+Q_{n-1,k-1}+\binom{n}{k}, \quad\text{\lr{for $n,k>0$.}}

Notice that 0 should be inside the inner formula.