3

I'm working in LyX in Hebrew, by using the "use non-TeX fonts (via XeTeX/LuaTeX)" option. The document is in Hebrew, and when I insert a math equation LyX automatically wraps it with \LRE{} to ensure left-to-right formatting. Most of the time there is no problem, however if I end a list item with a displayed equation, I will get a very big space (see picture and MWE). Is there a way to solve this (other than manually adding negative horizontal space each time)?

Example

\documentclass[english,hebrew]{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{David CLM}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
\begin{enumerate}
\item בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה\LRE{
\[
a=b
\]
}בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה\LRE{
\[
c=d
\]
}
\item ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
\end{enumerate}
\end{document}

1 Answer 1

3

I am not allowed to add this solution as a comment, so I post it as an answer. You can use \offinterlineskip to fix the problem. See David Carlisle's answer to this question for more information.

\documentclass[english,hebrew]{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{DavidCLM-Medium}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}

\newdimen\oldbaselineskip
\newdimen\oldlineskip
\newdimen\oldlineskiplimit
\def\itemWithPreDisplayMath{
  \oldbaselineskip\baselineskip
  \oldlineskip\lineskip
  \oldlineskiplimit\lineskiplimit
  \offinterlineskip
  \item
  \baselineskip \oldbaselineskip
  \lineskip \oldlineskip
  \lineskiplimit \oldlineskiplimit
}

\begin{document}
\begin{enumerate}
\item % or \itemWithPreDisplayMath, whichever you want.
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
\LRE{
\[
a=b
\]
}
\itemWithPreDisplayMath
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
 בלה בלה כל מיני טקסט לא חשוב רק רוצה שיגיע לאמצע השורה
\LRE{
\[
a=b
\]
}
 בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה
 בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה
 בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה
 בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה
 בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה
 בלה בלה עוד טקסט לא מעניין רק רוצה שיגיע לאמצע השורה
\LRE{
\[
c=d
\]
}
\itemWithPreDisplayMath
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
\end{enumerate}
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה
 ורק עוד קצת טקסט לשם הבהרה רק רוצה שיגיע לאמצע השורה

\end{document}

The output is: enter image description here

7
  • Also - I would really like a global solution - one that I don't have to apply manually each time...
    – Ur Ya'ar
    Aug 15, 2021 at 7:47
  • 1
    I have edited the answer and hope this works fine.
    – dma8hm1334
    Aug 16, 2021 at 6:21
  • This seems much better! There's still a bit larger gap between the items but I guess it's OK to have some distinction. Do you think I can simply redefine \item with this tweak? Cause I don't think I can use this new item in LyX, which is my main workspace (I mean I can use it with ERT but I'd prefer to use it just as I use a regular item).
    – Ur Ya'ar
    Aug 16, 2021 at 7:35
  • Or perhaps there's an option to add an argument to \item ?
    – Ur Ya'ar
    Aug 16, 2021 at 7:47
  • 1
    The extra vertical space is the default behavior in LaTeX. If I were you, I would not redefine \item because it may have been used to define other commands. However, if you want to do that, reset the definition as soon as possible. (Please note that I am a simple end user of TeX and its friends.)
    – dma8hm1334
    Aug 16, 2021 at 11:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .