考虑这个例子,为什么两种情况下列表前的空间不一样,以及当我在框架内改变文本方向时如何修复它。
\documentclass{beamer}
\usepackage[nil,bidi=basic-r,layout=counters]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{sf}{Amiri}
\mode<presentation>{\usetheme{Madrid}}
\begin{document}
\begin{frame}{Text}
\selectlanguage{nil} % change to LTR occur inside frame
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\selectlanguage{nil} % change to LTR occur outside frame
\begin{frame}{}
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\end{document}
更新
@DavidPurton 的回答工作正常,但使用框架标题时问题出现在第二框架中。
\documentclass{beamer}
\usepackage[nil,bidi=basic-r,layout=counters.lists]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{sf}{Amiri}
\mode<presentation>{\usetheme{Madrid}}
\begin{document}
\begin{frame}{Text}
\selectlanguage{nil} % change to LTR occur inside frame
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\selectlanguage{nil} % change to LTR occur outside frame
\begin{frame}{Text}
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\end{document}
答案1
babel 设置了错误的\shapemode
。恕我直言,如果你想改变整个框架,你\pagedir
也应该改变:
\documentclass{beamer}
\usepackage[nil,bidi=basic-r,layout=counters.lists]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{sf}{Amiri}
\mode<presentation>{\usetheme{Madrid}}
\begin{document}
\begin{frame}{Text}
\selectlanguage{nil} % change to LTR occur inside frame
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\begin{frame}{}
\selectlanguage{nil} % change to LTR occur inside frame
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\selectlanguage{nil} % change to LTR occur outside frame
\pagedir TLT %%added
\begin{frame}{Text}
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\begin{frame}{}
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\end{frame}
\end{document}
答案2
我无法确切地说出为什么会发生这种情况,但你需要包括layout=lists
。
摘自手册babel
§1.21:
列表
xetex
和中是必需的pdftex
,但仅限于 luatex 中的多语言文档。
由于您要从 RTL 切换到 LTR,我认为您需要此选项。无论如何似乎都有效。
因此尝试一下:
\usepackage[nil,bidi=basic-r,layout=counters.lists]{babel}
答案3
这里有一个解决方法,即pardir
在框架的开头进行测试并将其与pardir
列表的开头进行比较,如果它们不同,我们就\shapemode=2
在列表主体的开头添加。
\documentclass{beamer}
\usepackage[nil,bidi=basic-r,layout=counters]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{sf}{Amiri}
\usetheme{Madrid}
\newcounter{beginframepardir}
\makeatletter
\let\oldframe\frame
\def\frame{\setcounter{beginframepardir}{\bbl@getluadir{par}}
% 0 for TLT 1 for TRT
\oldframe}
\setbeamertemplate{itemize/enumerate body begin}{\ifnum\value{beginframepardir}=\bbl@getluadir{par} \else\shapemode=2\fi}
\setbeamertemplate{description body begin}{\ifnum\value{beginframepardir}=\bbl@getluadir{par} \else\shapemode=2\fi}
\makeatother
\begin{document}
\begin{frame}{Text}
\selectlanguage{nil} % change to LTR occur inside frame
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\selectlanguage{arabic}
\begin{itemize}
\item first item
\item second item
\item third item
\end{itemize}
\end{frame}
\selectlanguage{nil} % change to LTR occur outside frame
\begin{frame}{Test}
\begin{enumerate}
\item first item
\item second item
\item third item
\end{enumerate}
\selectlanguage{arabic}
\begin{itemize}
\item first item
\item second item
\item third item
\end{itemize}
\end{frame}
\end{document}