![xepersian & polyglossia:尽管德语是主要语言,但章节编号是 rtl](https://linux22.com/image/469142/xepersian%20%26%20polyglossia%EF%BC%9A%E5%B0%BD%E7%AE%A1%E5%BE%B7%E8%AF%AD%E6%98%AF%E4%B8%BB%E8%A6%81%E8%AF%AD%E8%A8%80%EF%BC%8C%E4%BD%86%E7%AB%A0%E8%8A%82%E7%BC%96%E5%8F%B7%E6%98%AF%20rtl.png)
我有一份包含波斯语元素的文档。为了正确排版,我使用了xepersian
。不幸的是,这导致所有小节的编号都是 RTL 而不是 LTR,因此是 1.2.3 而不是 3.2.1。
我该如何改变这种情况?
最小工作示例:
\documentclass[11pt,a4paper]{article}
% Font and Language Packages
\usepackage{fontspec} % For font customization
\usepackage{xunicode} % Extra Unicode support
\usepackage{polyglossia} % Multilingual support
\usepackage{xepersian} % Persian (Farsi) support
% Define the Persian (Farsi) font
\newfontfamily\persianfont[Script=Arabic]{Amiri}
% Set Document Languages
\setmainlanguage{german} % Main document language
\setotherlanguages{persian, english} % Other languages used in the document
\begin{document}
% Table of Contents
\tableofcontents
% Sections and Subsections
\section{Einleitung} % German section
This is the introduction section.
\section{Pahlavi-Zukunftsvisionen} % German section
This is the Pahlavi-Zukunftsvisionen section.
\section{Exil-Zukunfts-Vergangenheits-Träumereien} % German section
A section containing subsections.
\subsection{QQ Bang Bang} % German subsection
This is the QQ Bang Bang subsection.
\subsubsection{Erinnerungen und Nostalgie} % German sub-subsection
This is the Erinnerungen und Nostalgie sub-subsection.
\subsection{Another Subsection} % German subsection
This is another subsection.
% Persian Text
\begin{persian}
این یک پاراگراف متن نمونه به زبان فارسی است. % A paragraph of Persian (Farsi) text.
این یک مثال از یک شعر به زبان فارسی است: % An example of a Persian (Farsi) poem.
\end{persian}
% English Text
\begin{english}
This is a paragraph of dummy text in English. % A paragraph of English text.
\end{english}
\end{document}
答案1
xepersian
当您的主要文本是波斯语时,此包非常有用,否则您必须配置很多东西才能有效使用它。相反,我建议使用该bidi
包,假设您只有少量波斯语句子。
这里我定义了一个新命令\persiantext
,将文本方向设置为从右到左,并使用正确的字体。当您有一些波斯语文本时,您只需使用它。
\documentclass[11pt,a4paper]{article}
% Font and Language Packages
\usepackage{fontspec} % For font customization
\usepackage{xunicode} % Extra Unicode support
\usepackage{polyglossia} % Multilingual support
\usepackage{bidi} % For RTL support
% Define the Persian (Farsi) font
\newfontfamily{\persianfont}[Script=Arabic]{Vazirmatn}
% Set Document Languages
\setmainlanguage{german} % Main document language
\setotherlanguages{persian,english} % Other languages used in the document
% Command to set the text direction and font for Persian text
\newcommand{\persiantext}[1]{\begin{RTL} {\persianfont #1} \end{RTL}}
\begin{document}
% Table of Contents
\tableofcontents
% Sections and Subsections
\section{Einleitung} % German section
This is the introduction section.
\section{Pahlavi-Zukunftsvisionen} % German section
This is the Pahlavi-Zukunftsvisionen section.
\section{Exil-Zukunfts-Vergangenheits-Träumereien} % German section
A section containing subsections.
\subsection{QQ Bang Bang} % German subsection
This is the QQ Bang Bang subsection.
\subsubsection{Erinnerungen und Nostalgie} % German sub-subsection
This is the Erinnerungen und Nostalgie sub-subsection.
\subsection{Another Subsection} % German subsection
This is another subsection.
% Persian Text
\persiantext{
این یک پاراگراف متن نمونه به زبان فارسی است. % A paragraph of Persian (Farsi) text.
این یک مثال از یک شعر به زبان فارسی است: % An example of a Persian (Farsi) poem.
}
% English Text
\begin{english}
This is a paragraph of dummy text in English. % A paragraph of English text.
\end{english}
\end{document}