我正在编写希伯来语文档,代码中的括号是相反的。它们在常规模式下没有问题,但是当我更改字体样式时,括号就变成了相反的:
以下是 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}
您知道如何修复它吗?
谢谢!
答案1
您需要明确切换到拉丁 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}