我遇到了一个非常奇怪的问题。当语言设置为英语时,sections
和在我的输出中正确显示。但是当我将语言更改为希伯来语时(需要使用希伯来语才能正确显示 RTL 语言),和就乱了。我需要了解为什么会发生这种情况以及如何修复它。subsections
sections
subsections
两个例子之间唯一的变化是\setmainlanguage{english}
改为\setmainlanguage{hebrew}
。
理想的答案是使用该hebrewnumerals
功能,但只显示数字的相关subsection
部分section
。例如,用 2 代替 1.1.2,或者用 ב 代替 א.א.ב
示例 1:
示例 2:
XeLaTeX
MWE:(使用 Cardo 字体编译)
\documentclass[paper=a5,pagesize=pdftex]{scrbook}
\usepackage[top=2cm,bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lettrine}
\usepackage{xltxtra}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage[toc]{multitoc}
\usepackage{setspace}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}
\setcounter{tocdepth}{0}
\setcounter{secnumdepth}{2}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Cardo}
% sets the marks to be used (section and subsection)
\setmarks{section}{subsection}
\newlength\howwide
\newcommand\defhowwide{
\ifnumless{\value{section}}{99}{\ifnumgreater{\value{section}}{8}{\setlength{\howwide}{2.5em}}{\setlength{\howwide}{1.2em}}}{\ifnumgreater{\value{section}}{98}{\setlength{\howwide}{3.5em}}{\setlength{\howwide}{2.5em}}}
}
% sections and subsections formatting
\titleformat{\section}{}{\lettrine{\thesection}}{0em}{}[\vskip-1\baselineskip]
\titleformat{\subsection}[runin]{\small\bfseries}{\thesubsection}{1em}{}
\titlespacing{\section}{\howwide}{-1pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{1em}
\setlength{\parindent}{0pt}
\newlength\NumLen
\newlength\LinLen
% indents one line of text. Indentation= width of section number + 1em
\newcommand\IndOne{%
\setlength\NumLen{\howwide}
\addtolength\NumLen{0.5em}
\setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
\parshape 2 \NumLen \LinLen 0pt \textwidth}
% indents two lines of text. Indentation= width of section number + 1em
\newcommand\IndTwo{%
\setlength\NumLen{\howwide}
\addtolength\NumLen{0.5em}
\setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
\parshape 3 \NumLen \LinLen \NumLen \LinLen 0pt \textwidth}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{english}
\begin{document}
\mainmatter
\newlength{\myIndent}
\setcounter{section}{0}
\addtocounter{chapter}{1}
\setcounter{section}{0}
\defhowwide
\section{}
\settowidth{\myIndent}
{\IndOne בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ׃}
\ifdimless{\the\myIndent}
{\textwidth-\howwide+0.75em}
{\IndOne בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ׃ \stepcounter{subsection}
\subsection{} \IndOne וְהָאָרֶץ הָיְתָה תֹהוּ וָבֹהוּ וְחֹשֶׁךְ עַל־פְּנֵי תְהֹום וְרוּחַ אֱלֹהִים מְרַחֶפֶת עַל־פְּנֵי הַמָּיִם׃}
{\IndTwo בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ׃ \stepcounter{subsection} \subsection{} וְהָאָרֶץ הָיְתָה תֹהוּ וָבֹהוּ וְחֹשֶׁךְ עַל־פְּנֵי תְהֹום וְרוּחַ אֱלֹהִים מְרַחֶפֶת עַל־פְּנֵי הַמָּיִם׃}
\subsection{} וַיֹּאמֶר אֱלֹהִים יְהִי אֹור וַיְהִי־אֹור׃
\end{document}
答案1
主要问题可能是你正在定义命令前你加载polyglossia
。由于在选择 RTL 语言时polyglossia
会加载包,并对包命令进行各种修改,因此自己进行所有修改非常重要bidi
bidi
后加载polyglossia
并设置语言。
一般来说,这是一种独立于以下方面的良好做法polyglossia
:首先加载包,然后执行命令(重新)定义。