# multiple Persian and latin font in latex Equation

i have this latex code:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$\mathrm{P} 4.2$ Consider the sequence $x(n)=(0.9)^{n} \cos (\pi n / 4) u(n) .$ Let
$y(n)=\left\{\begin{array}{ll}{x(n, 2),} & {n=0, \pm 2, \pm 4, \cdots} \\ {0,} & {\text { otherwise }}\end{array}\right.$
1. The z-transform $Y^{\prime}(z)$ of $v(n)$ in terms of the $z$ -transform $X(z)$ of $x(n)$ : Consider
\begin{aligned} Y(\tau) &=\sum_{n=-\infty}^{\infty} y(n) z^{-n}=\sum_{n=-\infty}^{\infty} x(n / 2) z^{-4} ; n=0, \pm 1, \pm 2, \ldots \\ &=\sum_{n=-\infty}^{\infty} x(n) z^{-2 n}=\sum_{m=-\infty}^{\infty} x(m)\left(z^{2}\right)-X\left(z^{2}\right) \end{aligned}
2. The z-transfiorm of $r(n)$ is giver by \begin{aligned} X(z)=&=\left\{[0.9)^{\prime \prime} \cos (\pi n ; 4)\right]=\frac{1-\left[(0.9)(05(\pi / 4)] t^{-1}\right.}{1-2(0.9) \cos (\pi / 4)]=}+(0.9)^{2} z^{-2} \\=& \frac{-11.53642^{-1}}{1-1.27280+0.81=}:|z|>0.9 \\ & r=1=\frac{1-0.6264-2}{1-1.2728 \cdot 2+0.81=-1} ; \quad \sqrt{1.9}=0.3487 \end{aligned}

\end{document}


like this output:

an like to change the English text like consider to Farsi text like در نظر گرفتن so how could i do it?

i tried to do it by removing the Eng to Farsi by this kind:

\documentclass{article}
\usepackage{mathtools}
\usepackage{xepersian}
\settextfont{Titr}
\setlatintextfont{Lato Thin}

\begin{document}

$\mathrm{P} 4.2$
\textbf{در نظر گرفتن }
the sequence $x(n)=(0.9)^{n} \cos (\pi n / 4) u(n) .$
$y(n)=\left\{\begin{array}{ll}{x(n, 2),} & {n=0, \pm 2, \pm 4, \cdots} \\ {0,} & {\text { otherwise }}\end{array}\right.$
1. تبدیل Z  $Y^{\prime}(z)$ of $v(n)$ in terms of the $z$ -transform $X(z)$ of $x(n)$ : Consider
\begin{aligned} Y(\tau) &=\sum_{n=-\infty}^{\infty} y(n) z^{-n}=\sum_{n=-\infty}^{\infty} x(n / 2) z^{-4} ; n=0, \pm 1, \pm 2, \ldots \\ &=\sum_{n=-\infty}^{\infty} x(n) z^{-2 n}=\sum_{m=-\infty}^{\infty} x(m)\left(z^{2}\right)-X\left(z^{2}\right) \end{aligned}
2. The z-transfiorm of $r(n)$ is giver by \begin{aligned} X(z)=&=\left\{[0.9)^{\prime \prime} \cos (\pi n ; 4)\right]=\frac{1-\left[(0.9)(05(\pi / 4)] t^{-1}\right.}{1-2(0.9) \cos (\pi / 4)]=}+(0.9)^{2} z^{-2} \\=& \frac{-11.53642^{-1}}{1-1.27280+0.81=}:|z|>0.9 \\ & r=1=\frac{1-0.6264-2}{1-1.2728 \cdot 2+0.81=-1} ; \quad \sqrt{1.9}=0.3487 \end{aligned}

\end{document}


but the output don't changed correctly like this:

Thanks.

First of all, it looks like you don't have the font Lato Thin in your system. Install it first. (Or delete it and process) Second, your editor must be bidirectional; Like texstudio or biditexmaker .... Third, in the Persian text for writing English you must use the \lr{text} command.