[Tex/LaTex] Xepersian package prints persian text but does not recognize formulas and gives error

xepersian

I have used MiKTeX for many works in last year. I didn't have a problem installing it. But now I am trying to install it on my new laptop. It's killing me with an ocean of errors. it has been two weeks, after tackling hundreds of errors finally I have been able to make it recognize Persian text. For example:

\documentclass{book}
\usepackage{xepersian}
\begin{document}
سلام
\end{document}

and it successfully prints the pdf file when typeset by XeLaTeX. But when I add a simple formula like the following:

\documentclass{book}
\usepackage{xepersian}
\begin{document}
سلام
\[e^{i\pi}+1=0\]
\end{document}

it will not give any output, instead the following error shows up:

! Undefined control sequence.
\SetMathCode #1#2#3#4->\Umathcode 
                                  #1="\mathchar@type #2 \csname sym#3\endcsn...
l.5 \[
      e^{i\pi}+1=0\]
?

What should I do? I am tired of examining various unhelpful solutions. I already installed and uninstalled MiKTeX many times. I downloaded Persian modern installed and put them in my windows. and many many many many other things I have done that I dont want to bore you with…..
Many forums suggested to use TeX Live instead but I don't want to use that. It seems like another kind of problem that cant be solved by just changing the software. I want to know what is the problem with this software?

Best Answer

Sina, I find the tone of your language slightly (and uselessly) aggressive. The solutions you tried perhaps was your own solutions; well you may never talked about the problem with an expert; at least you did not contact us (maintainer of xepersian).

So what is the problem? In new version of XeTeX, \XeTeXmathcode and \XeTeXmathchardef are depreciated and so we changed them in new version of xepersian to \Umathcode and \Umathchardef. MikTeX still ships the old xetex binary and so you get the error. If you want to use MiKTeX, then as a workaround, add the following lines to the preamble of your tex document:

\makeatletter
\@ifundefined{Umathcode}{\let\Umathcode\XeTeXmathcode}{}
\@ifundefined{Umathchardef}{\let\Umathchardef\XeTeXmathchardef}{}
\makeatother 

Or better install TeXLive 2013 (when it will be officially released).

Related Question