I am working with multiple languages (with polyglossia
and XeLaTeX
), and I am having issues with extra line breaks where I don't expect them, also likely related to an issue of not hyphenating where it should. See the minimal example below. The line surprisingly breaks after the first word (זײַן) of every third entry, and puts a line-break instead of hyphenating at the discretionary hyphens. I believe that this has something to do with the \hfil
in \entry
, as suggested by this answer, but I don't want to get rid of \hfil
(replacing it with \hspace{0.1cm plus 0.1cm}
, for example), as I need both the left and right sides to be justified. Additionally, the last two entries show that it may also have to do with the interaction between the Yiddish text and the English text, as TeX hyphenates at the normal hyphen when there is no Yiddish, but it fails to hyphenate when there is Yiddish. The parbox
at the very end of the sample code shows that \maq
is a valid hyphenation spot, outside of my \entry
environment, however after that I show that the hyphenation doesn't work properly in a normal paragraph, outside of \parbox
.
I would like the right-hand side to fill the space before breaking (and in fact, I have manually edited the first three entries to appear as I expect all the entries to appear).
\documentclass[10pt]{book}
\usepackage{polyglossia}
\usepackage{multicol}
\usepackage{geometry}
\setdefaultlanguage{english}
\setotherlanguages{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Arial Unicode MS}
\newcommand\maq{\discretionary{־}{}{־}}
\newcommand{\h}[1]{\RL{\texthebrew{#1}\hfil}}
\newcommand{\hangparagentry}{\hangindent-0.5em \hangafter1 \leftskip 0.8em \parindent -0.5em}
\DeclareDocumentCommand{\entry}{ m o m }{\strut\noindent\hangparagentry{\hspace{-.5em}\textbf{#1}\hspace{0.1cm}\hfil \h{{#3}\IfNoValueF{#2}{ \textenglish{\scriptsize{#2}}}}\par}\strut}
\begin{document}
\setlength{\columnsep}{0.75pc}
\setlength{\columnseprule}{0.4pt}
\flushright
\begin{multicols}{2}
\entry{vehicle identification number}{דער אױטאָ־ אידענטיפֿיציר\maq נומער, ־ן}
\entry{vehicle inspection program}{די אױטאָ־ אינספּעקטיר\maq פּראָגראַם, ־ען}
\entry{be eager to be eager to}[[BALN] [KhÉYShEK] [LÓET/LÓER]]{זײַן אַ בעלן צו; האָבן \\ \hspace{0.5em} חשק צו; זײַן נײַגעריק ‹להוט› צוצו; האָבן צו; זײַן נײַגעריק ‹להוט› צוצו; צו; זײַן נײַגעריק ‹להוט› צו; זײ֜ער ‹שטאַרק› װעלן}
\entry{vehicle identification number}{דער אױטאָ\maq אידענטיפֿיציר\maq נומער, ־ן}
\entry{vehicle inspection program}{די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען}
\entry{be eager to be eager to}[[BALN] [KhÉYShEK] [LÓET/LÓER]]{זײַן אַ בעלן צו; האָבן חשק צו; זײַן נײַגעריק ‹להוט› צוצו; האָבן צו; זײַן נײַגעריק ‹להוט› צוצו; צו; זײַן נײַגעריק ‹להוט› צו; זײ֜ער ‹שטאַרק› װעלן}
\entry{vehicle identification number}{דער אױטאָ\maq אידענטיפֿיציר\maq נומער, ־ן}
\entry{vehicle inspection program}{די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען}
\entry{be eager to be eager to}[[BALN] [KhÉYShEK] [LÓET/LÓER]]{זײַן אַ בעלן צו; האָבן חשק צו; זײַן נײַגעריק ‹להוט› צוצו; האָבן צו; זײַן נײַגעריק ‹להוט› צוצו; צו; זײַן נײַגעריק ‹להוט› צו; זײ֜ער ‹שטאַרק› װעלן}
\entry{vehicle identification number}{דער אױטאָ\maq אידענטיפֿיציר\maq נומער, ־ן}
\entry{vehicle inspection program}{די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען}
\entry{be eager to be eager to}[[BALN] [KhÉYShEK] [LÓET/LÓER]]{זײַן אַ בעלן צו; האָבן חשק צו; זײַן נײַגעריק ‹להוט› צוצו; האָבן צו; זײַן נײַגעריק ‹להוט› צוצו; צו; זײַן נײַגעריק ‹להוט› צו; זײ֜ער ‹שטאַרק› װעלן}
\entry{vehicle identification number}{די \textenglish{tests-testing}}
\entry{vehicle identification number}{\textenglish{tests-longtestings}}
\end{multicols}
\parbox{0pt}{\h{דער אױטאָ\maq אידענטיפֿיציר\maq נומער, ־ן}}
\h{די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען די אױטאָ\maq אינספּעקטיר\maq פּראָגראַם, ־ען}
\end{document}
\parbox
at the end show that hyphenation is possible, but you're right, it doesn't seem to work in a normal paragraph. Unfortunately, it seems like the interaction between the Hebrew characters and Latin characters are part of the problem, so I can't get simplify my question that way.