1

Working off of this question, I see that XeLaTeX is inconsistently applying hyphenation to my text. As you can see in the MWE, in the paragraph before the \entry, hyphenation is not applied, yet in the same text after the \entry, it is. I can't understand what about the \entry is changing this hyphenation. To be clear, I would like hyphenation to always be applied.

\documentclass[10pt]{book}
\usepackage{polyglossia}

\setdefaultlanguage{english}
\setotherlanguages{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Arial Unicode MS}

\newcommand{\h}[1]{\RL{\texthebrew{#1}\hfil}}
\newcommand{\hangparagentry}{\hangindent-0.5em \hangafter1 \leftskip 0.8em \parindent -0.5em}

\DeclareDocumentCommand{\entry}{ m o m }{%
  \noindent\hangparagentry{\hspace{-.5em}\textbf{#1}\hspace{0.5cm} %\hfill
  \h{\hspace{0pt}#3\IfNoValueF{#2}{ \textenglish{\scriptsize{#2}}}}}\par}

\begin{document}

\flushright


\h{דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס }

\entry{anything}{\textenglish{blah}}

\h{דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס }

\end{document}
  • \flushright is not a command to be used on its own; you probably mean \raggedleft – egreg Oct 27 '15 at 17:58
  • @egreg Fair. However, I don't want the left side to be ragged -- I want justified sides, but right-to-left. See my comment on jarauh's answer below. – magicker72 Oct 27 '15 at 20:41
1

In \hangparagentry, you do a lot of changes to the parameters of the paragraph. These changes persist after the end of \entry. To make these changes local, you can, for example, add additional curly braces:

\DeclareDocumentCommand{\entry}{ m o m }{{%
  \noindent\hangparagentry{\hspace{-.5em}\textbf{#1}\hspace{0.5cm} %\hfill
  \h{\hspace{0pt}#3\IfNoValueF{#2}{ \textenglish{\scriptsize{#2}}}}}}\par}

Basically, it is the command \flushright that prevents the hyphenation in the first place. \flushright sets \leftskip to a flexible value that prevents hyphenations.

As egreg suggested in a comment to another question, if you want both ragged left and hyphenation, you can use:

\leftskip=0em plus 2em
  • That changes the location of the word "anything", which I don't want. Additionally, I do want the hyphenation. Is there a way to \flushright without messing up \leftskip, ie. right-align everything without changing other parameters? – magicker72 Oct 27 '15 at 17:53
  • Well, in a \flushright environment, all text is aligned at the right, and the left border is allowed to be ragged. Thus, no reason for hyphenation. Why would you want hyphenation, and according to what criterion? – jarauh Oct 27 '15 at 17:57
  • I chose \flushright because it would give me a right-to-left setting (ie. a line that isn't full would start on the right side of the page instead of on the left). I want fully justified lines, so \raggedleft is not an option, and I want hyphenations like TeX normally does English hyphenations in justified left-to-right text. – magicker72 Oct 27 '15 at 18:32
1

The command \h is not supposed to be used for running text.

\documentclass[10pt]{book}
\usepackage{polyglossia}

\setdefaultlanguage{english}
\setotherlanguages{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Arial Unicode MS}

\newcommand{\h}[1]{\RL{\texthebrew{#1}\hfil}}
\newcommand{\hangparagentry}{\hangindent-0.5em \hangafter1 \leftskip 0.8em \parindent -0.5em}

\DeclareDocumentCommand{\entry}{ m o m }{%
  \noindent{\hangparagentry{\hspace{-.5em}\textbf{#1}\hspace{0.5cm} %\hfill
  \h{\hspace{0pt}#3\IfNoValueF{#2}{ \textenglish{\scriptsize{#2}}}}}\par}}

\NewDocumentCommand{\hh}{O{}m}{%
  \begin{RTL}\begin{otherlanguage*}{hebrew}%
  #1#2\par
  \end{otherlanguage*}\end{RTL}%
}

\begin{document}


\hh[\sloppy]{דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער
  ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער
  ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער,
 -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס}

\entry{earthquake meter earthquake meter earthquake meter}{דער ע֜רד-צי֜טערניש-מע֜סטער, -ס}

\hh[\sloppy]{דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער
  ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער
  ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס דער
  ע֜רד-צי֜טערניש-מע֜סטער, -ס דער ע֜רד-צי֜טערניש-מע֜סטער, -ס}

\end{document}

Note \sloppy because otherwise one line in the paragraph would be overfull.

enter image description here

  • That answers the question as asked. What about if I wanted to have English text in the same paragraph? Since the RTL environment inserts a line break before and after, it splits what I want to be one paragraph into three. – magicker72 Oct 27 '15 at 21:30
  • @magicker72 I suggest reading the manual of bidi. – egreg Oct 27 '15 at 21:30

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.