1

I'm writing Hebrew document and the brackets at the code are opposite. They are ok at the regular mode but when I change the font style the brackets became opposite:
enter image description here

And here is MWE:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{fontspec}


\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Bellefair}


\usepackage{listings}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}


\begin{document}
\begin{english}[variant=american]%
\begin{lstlisting}[language=Python,numbers=left,basicstyle={\ttfamily}]
a=(1)
b=[2]
\end{lstlisting}
\end{english}%

\end{document}

Do you know how to fix it?
Thank you!!

5

You need to switch explicitly to the latin tt:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{fontspec}


\newfontfamily\hebrewfont[Script=Hebrew]{Arial}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Arial}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Arial}


\usepackage{listings}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}


\begin{document}

\begin{english}[variant=american]%

\begin{lstlisting}[language=Python,numbers=left,basicstyle={\ttfamilylatin}]
a=(123)
b=[2]
\end{lstlisting}
\end{english}%

\end{document}

enter image description here

| improve this answer | |

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.