2

I use Latex and babel to do my homework in Hebrew. I also use the witharrows package to make arrows explaining steps in equations. It usually works fine:

However, when I try to add Hebrew text to explain what I did, the inline equation in the \Arrow{} breaks and uses RTL direction, which is obviously wrong for math:

Why does this happen and how can I fix this?

Here's a MWE:

\documentclass[a4paper, 12pt]{article}

\PassOptionsToPackage{no-math}{fontspec}

\usepackage[bidi=basic, layout=tabular, headfoot=hebrew]{babel}

% For Hebrew
\babelprovide[main, import, alph=letters, Alph=letters]{hebrew}
\babelprovide[import]{english}

% For English
% \babelprovide[main, import]{english}
% \babelprovide[import, alph=letters, Alph=letters]{hebrew}

\babelfont[hebrew]{rm}{David CLM}
\babelfont[hebrew]{sf}{David CLM}

\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{witharrows}

% witharrows options
\WithArrowsOptions{displaystyle}

\tikzset{text=.}
\tikzset{
    WithArrows/arrow/.append style = {
        font= \small
    }
}

\begin{document}
נחשב את הגבול
\( \lim_{x \to \infty} f(x) \):
\begin{DispWithArrows*}
    L &= \lim_{x \to \infty} f(x) \\
    &= \lim_{x \to \infty} xP(x) e^{-x^2} \Arrow{\( Q(x) \coloneq xP(x) \) פולינום} \\
    &= \lim_{x \to \infty} Q(x) e^{-x^2}
\end{DispWithArrows*}
\end{document}
1

1 Answer 1

0

I don't have any explanation for that problem but, as workaround, you can put the equation in a \hbox of TeX.

\documentclass[a4paper, 12pt]{article}

\PassOptionsToPackage{no-math}{fontspec}

\usepackage[bidi=basic, layout=tabular, headfoot=hebrew]{babel}

% For Hebrew
\babelprovide[main, import, alph=letters, Alph=letters]{hebrew}
\babelprovide[import]{english}

% For English
% \babelprovide[main, import]{english}
% \babelprovide[import, alph=letters, Alph=letters]{hebrew}

\babelfont[hebrew]{rm}{David CLM}
\babelfont[hebrew]{sf}{David CLM}

\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{witharrows}

% witharrows options
\WithArrowsOptions{displaystyle}

\tikzset{text=.}
\tikzset{
    WithArrows/arrow/.append style = {
        font= \small
    }
}

\begin{document}
נחשב את הגבול
\( \lim_{x \to \infty} f(x) \):
\begin{DispWithArrows*}
    L &= \lim_{x \to \infty} f(x) \\
    &= \lim_{x \to \infty} xP(x) e^{-x^2} \Arrow{\hbox{\( Q(x) \coloneq xP(x)\)} פולינום} \\
    &= \lim_{x \to \infty} Q(x) e^{-x^2}
\end{DispWithArrows*}
\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .