当我使用 babel 包来支持希伯来语时,文档中的框架列表看起来很奇怪,带有背景颜色的列表也是如此。
知道如何解决吗?
以下是 MWE:
\documentclass[]{article}
\usepackage[hebrew,english]{babel}
\usepackage{listings}
\usepackage{color}
\begin{document}
\section*{First Listing}
\begin{lstlisting}[]
this
is
a
simple
listing
\end{lstlisting}
\section*{Second Listing}
\begin{lstlisting}[frame=single]
this
is
a
simple
listing with frame
\end{lstlisting}
\section*{Third Listing}
\begin{lstlisting}[backgroundcolor=\color{red}]
this
is
a
simple
listing with background color
\end{lstlisting}
\section*{Forth Listing}
\begin{lstlisting}[frame=single,backgroundcolor=\color{red}]
this
is
a
simple
listing with frame and background color
\end{lstlisting}
\end{document}
谢谢。
答案1
希伯来语更改\everypar
和列表不喜欢这样。您可以在列表开头重置原始定义:
附注:您可以使用 tcolorbox 制作更好的框架和背景。
\documentclass[]{article}
\usepackage[hebrew,english]{babel}
\usepackage{listings}
\usepackage{color}
\makeatletter
\lst@AddToHook{PreInit}{\let\everypar\o@everypar }
\makeatother
\begin{document}
\section*{First Listing}
\begin{lstlisting}[]
this
is
a
simple
listing
\end{lstlisting}
\section*{Second Listing}
\begin{lstlisting}[frame=single]
this
is
a
simple
listing with frame
\end{lstlisting}
\section*{Third Listing}
\begin{lstlisting}[backgroundcolor=\color{red}]
this
is
a
simple
listing with background color
\end{lstlisting}
\section*{Forth Listing}
\begin{lstlisting}[frame=single,backgroundcolor=\color{red}]
this
is
a
simple
listing with frame and background color
\end{lstlisting}
\end{document}