3

I'd like to insert an equation in my $LaTeX$ document that looks like the following equation but I fail to make it show the text inside the equation:

enter image description here

and the output I am getting:

enter image description here

I read questions\answers regarding the combination of Persian and English in xepersian and used \lr and latin but it doesn't work. What am I doing wrong?

Here is the MWE:

\documentclass[a4paper,12pt]{report}
\usepackage{titlesec}
\usepackage{xepersian}
\usepackage{./styles/tempfix}
\settextfont[Scale=1.1]{B Nazanin}
\defpersianfont\nastaliq[Scale=2]{IranNastaliq}
\defpersianfont\titr[Scale=1]{B Titr}
\defpersianfont\traffic[Scale=1]{B Traffic}
\deflatinfont\calibri{Calibri}
\begin{document}

\begin{equation}
P_J{:}\quad \min_{x} J(x) \quad \textrm{subject to} \quad y=Dx
%P_J{:}\quad \min_{x} J(x) \quad \lr\textrm{subject to} \quad y=Dx
\end{equation}
\end{document}

There is a similar question which was closed.

5
  • 1
    Quick guess: maybe \text{} and \mathrm{} could be useful. See also this question. – Karlo Aug 16 '16 at 11:16
  • Minimal example? – egreg Aug 16 '16 at 11:17
  • 1
    Oh \mathrm{} works, thank you for the quick guess @Karlo! :) – Gigili Aug 16 '16 at 11:26
  • Not a minimal example: I get an error: You have not specified any font for the main Persian text. – egreg Aug 16 '16 at 11:46
  • @egreg oops, sorry! Edited. – Gigili Aug 16 '16 at 11:59
3

Your Persian font doesn't seem to support Latin character. If I use Scheherazade, it does:

\documentclass[a4paper,12pt]{report}

\usepackage{unicode-math}
\usepackage{xepersian}

\setmainfont{TeX Gyre Termes}
\setmathfont{XITS Math}
\settextfont[Scale=MatchUppercase]{Scheherazade}

\begin{document}

\begin{equation}
P_J{:}\quad \min_{x} J(x) \quad \textrm{subject to} \quad y=Dx
\end{equation}

\end{document}

enter image description here

Alternatively,

\documentclass[a4paper,12pt]{report}
\usepackage{amsmath}
\usepackage{xepersian}

\settextfont[Scale=MatchUppercase]{Scheherazade}

\begin{document}

\begin{equation}
P_J{:}\quad \min_{x} J(x) \quad \textnormal{\lr{subject to}} \quad y=Dx
\end{equation}

\end{document}

enter image description here

2
  • Thank you for your answer but I really don't like to change the font. – Gigili Aug 16 '16 at 12:00
  • @Gigili The alternative version doesn't require font changes; I used Scheherazade because that's the font I have. – egreg Aug 16 '16 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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