启用希伯来语后,多语种部分的位置会有所不同

启用希伯来语后,多语种部分的位置会有所不同

我发现当启用希伯来语时,Polyglossia 会将该部分放置在不同的位置。

MWE 如下:在 XeLaTeX 中运行

\documentclass[pagesize=pdftex, fontsize=8]{scrbook}
\usepackage[paperwidth=7.5cm, paperheight=11cm, top=1cm,bottom=0.4cm, left=0.5cm, right=0.5cm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lettrine}
\usepackage{xltxtra}
\usepackage{needspace}
\usepackage{calc}

\usepackage[nospread]{flushend}

\setlength{\hoffset}{0cm}

\usepackage[none]{hyphenat}
\tolerance=150
\widowpenalty=1000
\sloppy

\usepackage{polyglossia} 
    \setmainlanguage{english} 
%   \setotherlanguage{hebrew} %++++++++++++

\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Times New Roman}
\newfontfamily\hebrewfont[Script=Hebrew]{Times New Roman}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Times New Roman}   

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}

% sets the marks to be used (section and subsection)
\setmarks{section}{subsection}

\linespread{0.85}%
\setlength{\headsep}{10pt}

\newlength\spaceBetweenNumberAndText
\setlength\spaceBetweenNumberAndText{0.5em}
\newlength\howwide

\newcommand\defhowwide{
    \setlength{\howwide}{\widthof{\Huge{\thesection}}}
}

% sections and subsections formatting
%\titleformat{command}[shape]{format}{label}{sep}{before-code}[after-code]
\titleformat{\section}{}{\Huge{\thesection}}{0pt}{}[\vskip-2.3\baselineskip]
\titleformat{\subsection}[runin]{\scriptsize}{\thesubsection}{1em}{}
%\titlespacing*{command}{left}{before-sep}{after-sep}[right-sep]
\titlespacing{\section}{0pt}{\spaceBetweenNumberAndText}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{0.5em}

\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{\spaceBetweenNumberAndText}
  \setlength\LinLen{\dimexpr\columnwidth-\NumLen}%\the\NumLen\the\LinLen
  %LTR differs here from RTL
  %\parshape 2 0pt \LinLen 0pt \columnwidth
  \parshape 2 \NumLen \LinLen 0pt \columnwidth
}

% indents two lines of text. Indentation = width of section number + 1em
\newcommand\IndTwo{
    \setlength\NumLen{\howwide}
    \addtolength\NumLen{\spaceBetweenNumberAndText}
    \setlength\LinLen{\dimexpr\columnwidth-\NumLen}%\the\NumLen\the\LinLen
    %LTR differs here from RTL
    %\parshape 3 0pt \LinLen 0pt \LinLen 0pt \columnwidth
    \parshape 3 \NumLen \LinLen \NumLen \LinLen 0pt \columnwidth
}

\begin{document}
\mainmatter
\setlength\columnseprule{0pt}
\newlength{\myIndent}
\flushcolsend
\twocolumn[\begin{center}\vspace{-0.5cm}THE GOSPEL ACCORDING TO SAINT\\ 
\vspace{0.1cm}{\Huge{MATTHEW}}\\\vspace{0.1cm}
\end{center}]
\addtocounter{chapter}{1}
\renewcommand{\chaptertitle}{Matthew}
\setcounter{section}{0}
%\begin{hebrew} %+++++++++++++
\section{} \defhowwide \settowidth{\myIndent}{\IndOne זֶה סֵפֶר תּוֹלְדֹת הַמָּשִׁיחַ יֵשׁוּעַ בֶּן־דָּוִד בֶּן־אַבְרָהָם׃}\ifdimless{\the\myIndent}{\columnwidth-\howwide}{\IndOne זֶה סֵפֶר תּוֹלְדֹת הַמָּשִׁיחַ יֵשׁוּעַ בֶּן־דָּוִד בֶּן־אַבְרָהָם׃ \stepcounter{subsection}\subsection{} \IndOne אַבְרָהָם הוֹלִיד אֶת־יִצְחָק וְיִצְחָק הוֹלִיד אֶת־יַעֲקֹב וְיַעֲקֹב הוֹלִיד אֶת־יְהוּדָה וְאֶת־אֶחָיו׃}{\IndTwo זֶה סֵפֶר תּוֹלְדֹת הַמָּשִׁיחַ יֵשׁוּעַ בֶּן־דָּוִד בֶּן־אַבְרָהָם׃\stepcounter{subsection}\subsection{} אַבְרָהָם הוֹלִיד אֶת־יִצְחָק וְיִצְחָק הוֹלִיד אֶת־יַעֲקֹב וְיַעֲקֹב הוֹלִיד אֶת־יְהוּדָה וְאֶת־אֶחָיו׃}
\subsection{} וִיהוּדָה הוֹלִיד אֶת־פֶּרֶץ וְאֶת־זֶרַח מִתָּמָר וּפֶרֶץ הוֹלִיד אֶת־חֶצְרוֹן וְחֶצְרוֹן הוֹלִיד אֶת־רָם׃
\subsection{} וְרָם הוֹלִיד אֶת־עַמִּינָדָב וְעַמִּינָדָב הוֹלִיד אֶת־נַחְשׁוֹן וְנַחְשׁוֹן הוֹלִיד אֶת־שַׂלְמוֹן׃
\subsection{} וְשַׂלְמוֹן הוֹלִיד אֶת־בֹּעַז מֶרָחָב וּבֹעַז הוֹלִיד אֶת־עוֹבֵד מֵרוּת וְעוֹבֵד הוֹלִיד אֶת־יִשָׁי׃
\subsection{} וְיִשַׁי הוֹלִיד אֶת־הַמֶּלֶךְ דָּוִד וְדָוִד הוֹלִיד אֶת־שְׁלֹמֹה מֵהָאִשָּׁה אֲשֶׁר לָקַח מֵאוּרִיָּה׃
\subsection{} וּשְׁלֹמֹה הוֹלִיד אֶת־רְחַבְעָם וּרְחַבְעָם הוֹלִיד אֶת־אֲבִיָּה וַאֲבִיָּה הוֹלִיד אֶת־אָסָא׃
\subsection{} וְאָסָא הוֹלִיד אֶת־יְהוֹשָׁפָט וִיהוֹשָׁפָט הוֹלִיד אֶת־יְהוֹרָם וִיהוֹרָם הוֹלִיד אֶת־עֻזִּיָּהוּ׃
%\end{hebrew} %+++++++++++++
\section{} \defhowwide \settowidth{\myIndent}{\IndOne Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem,}\ifdimless{\the\myIndent}{\columnwidth-\howwide}{\IndOne Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem, \stepcounter{subsection}\subsection{} \IndOne Saying, Where is he that is born King of the Jews? for we have seen his star in the east, and are come to worship him.}{\IndTwo Now when Jesus was born in Bethlehem of Judaea in the days of Herod the king, behold, there came wise men from the east to Jerusalem,\stepcounter{subsection}\subsection{} Saying, Where is he that is born King of the Jews? for we have seen his star in the east, and are come to worship him.}
\subsection{} When Herod the king had heard these things, he was troubled, and all Jerusalem with him.
\subsection{} And when he had gathered all the chief priests and scribes of the people together, he demanded of them where Christ should be born.
\subsection{} And they said unto him, In Bethlehem of Judaea: for thus it is written by the prophet,
\subsection{} And thou Bethlehem, in the land of Juda, art not the least among the princes of Juda: for out of thee shall come a Governor, that shall rule my people Israel.
\end{document}

\setotherlanguage{hebrew}\begin{hebrew}\end{hebrew}被禁用时,文本可以从左到右完美显示。

在此处输入图片描述

当您启用希伯来语时,它会弄乱章节和小节的放置。

在此处输入图片描述

这看起来像是 Polyglossia 包中的一个错误??

答案1

当前的问题是,当您启用希伯来语时,LaTeX 会加载 bidi 包。在 Scrbook 的定义文件中,bidi 使用本机 scrbook 命令\DeclareSectionCommand,该命令重新定义了各种分段命令。这会阻止您通过 titlesec 对常规分段命令进行的编辑生效,因为它们只会更改常规标题命令的内部内容,而不会更改 scrbook 命令的内部内容。

实际上,有两种方法可以继续。一种是顽固地滥用章节和小节,方法很简单(将其放在最初加载 polyglossia 的位置):

\usepackage{polyglossia} 
%saving away the old sectioning commands
\let\oldsection\section
\let\oldsubsec\subsection

\setmainlanguage{english} 
\setotherlanguage{hebrew} %++++++++++++

%and now bringing them back
\let\section\oldsection
\let\subsection\oldsubsec

或者,您可以定义自己的宏,正如 Ulrike 在评论中暗示的那样。

%setting up counters for cross refferencing
\newcounter{CHAPTER}
\newcounter{verse}
\makeatletter
\@addtoreset{CHAPTER}{verse}
\makeatother

%getting the chapter down, with the marks
\def\CHAPTER#1{%
  \par\stepcounter{CHAPTER}\refstepcounter{verse}%
  \markboth{\theCHAPTER}{\theverse}%
  {\HUGE\theCHAPTER}\par\vskip-2.3\baselineskip%
%You could even make this take a second argument, so it could use your other macro about the indentation. I didn't study its usage, so that's left for you to do
}

%and the verse, in similar fashion 
\def\verse#1{%
  \refstepcounter{verse}%
  \markright{\theverse}%
  {\scriptsize\theverse}\hspace{1.5em}%
}

这样做的好处是与 LaTeX 的理念保持一致,即清晰标记文本。不过 section 是指章节划分的一种合理方式。

相关内容