1

I have found that Polyglossia places the section differently when Hebrew gets enabled.

MWE follows: Run in 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}

When \setotherlanguage{hebrew} and \begin{hebrew} and \end{hebrew} is disabled the text displays perfectly LEFT to RIGHT.

enter image description here

When you enable the Hebrew, it messes up the placing of the Section and Subsections.

enter image description here

This seems like a mistake in the Polyglossia package??

  • 2
    If you enable hebrew you load the bidi package and this changes lots of things. I have no idea if titlesec actually works with bidi but imho you should better try to get your layout without it. – Ulrike Fischer Nov 9 '17 at 13:39
  • 1
    From working with your code, it's more of an issue with scrbook, because no problems show up using a standard document class. – A Gold Man Nov 12 '17 at 6:46
3

The problem at hand is that when you enable hebrew, LaTeX loads the bidi package. In the definitions file for Scrbook, bidi uses the native scrbook command \DeclareSectionCommand, which redefines the various sectioning commands. This prevents your edits to the normal sectioning commands through titlesec from taking effect, because they only change the internals of the normal titling commands, not the scrbook ones.

There are really two ways you could proceed from here. One is to stubbornly abuse sections and subsections, which is as simple as this (put this where you originally loaded 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

Alternatively, you could define your own macros, as Ulrike hinted to in the comments.

%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}%
}

This has the benefit of keeping in line with the LaTeX philosophy of having clearly marked up text. Though section is a fair way to refer to the division of a chapter.

| improve this answer | |
  • Brilliant! I was heading in the second option way but I'll investigate both solutions to see which works best for my purpose. Thanks – McGafter Nov 13 '17 at 10:26
  • @McGafter It's also plausible that titlesec being used with scrbook is a hack, based on the warning messages it gave. So you might be able to work around the issue by just loading titlesec after you set up hebrew as the otherlanguage – A Gold Man Nov 13 '17 at 11:50
  • Moving titlesec there seems to put me back to square one. You're first solution works satisfactorily at this point even though it gives two errors. – McGafter Nov 14 '17 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.