3

The following LaTeX code was saved in ~/test.tex.

\documentclass{article}
\usepackage{amsmath}

\newtheorem{theorem}{Theorem}

\usepackage{showlabels}

\iffalse \usepackage{polyglossia} \setmainlanguage{hebrew} \setmainfont{FreeSans}

% The following trick prevents a compilation error. See here: % https://tex.stackexchange.com/a/665086/21685 \renewcommand{\showlabelfont}{\textrm} \fi

\iffalse \usepackage[bidi=basic]{babel} \babelprovide[main,import]{hebrew} \babelfont{rm}{FreeSans} \fi \begin{document}

\begin{theorem}\label{T} A house is not a home. \end{theorem}

\begin{equation}\label{E} a = b + c \end{equation}

\begin{align} x &= y + z\label{A} \end{align}

\end{document}

When compiled with lualatex ~/test, the file ~/test.pdf was created, which, opened in a PDF viewer, displayed as follows. (The page number in the bottom of the page was deliberately not included in the screenshot.)

No Hebrew

Note that all numberings and labels show in the right margin. Furthermore, the equation numbers are properly surrounded by parentheses, and the labels are properly surrounded by braces.

I then activated the polyglossia block, by commenting the two lines surrounding it containing \iffalse and \fi, and reran lualatex ~/test. A file was created at ~/test.pdf, which, opened in a PDF viewer, displayed as follows. (The page number in the bottom of the page was again deliberately not included in the screenshot.)

Hebrew via polyglossia

As Hebrew is a right-to-left language, it is correct that the words be ordered from right to left, and that the paragraph be right-justified. Furthermore, note that equation numbers are properly surrounded by parentheses, and the labels are properly surrounded by braces.

However, the positions of the number and label of the standalone equation have shifted to the left margin, whereas the positions of the number and label of the aligned equation have remained as before, in the right margin.

Furthermore, the relative position of the label and number is the same for the standalone equation as for the aligned equation: the label is to the right of the number.

Next, I restored the polyglossia block to its original, dormant state, and activated the babel block. Having rerun lualatex ~/test, a file was created at ~/test.pdf, which, opened in a PDF viewer, displayed as follows. (The page number in the bottom of the page was once more deliberately not included in the screenshot.)

Hebrew via babel

In the standalone equation the number is properly surrounded by parentheses, and the label is properly surrounded by braces. However, in the aligned equation the parentheses face the wrong directions, as do the braces.

Note that the positions of the number and label of both the standalone and the aligned equation have remained as before along the right margin.


Three issues require attention.

The first, and more serious one, is the ill-facing parentheses and braces in the version typeset by babel. This is a serious problem, because unlike the labels, the parentheses and braces show in the output that is intended for public consumption. Furthermore, unlike the other two issues, this one is objectively wrong. Lastly, ill-facing parentheses/braces are just plain ugly and disorienting.

The second issue concerns the relative position of the label and the equation number of the standalone equation in the PDF file typeset with polyglossia. In my opinion, once the choice has been made to left-justify the equation number, the label should appear to the left of the number, below the theorem's label.

The third issue concerns the question: what is the "correct" position for equation numbers in a Hebrew text? I claim that it should be along the left margin (but with an important caveat, see below). My reasons are threefold.

  1. The labels should reside in the same margin as the one containing the labels of the various theorem environments, so the eye doesn't wonder from left to right in search of a label. The labels of the theorem environments are correctly placed in the margin farther from the environment's name, analogously to the way they are positioned in an English document.

  2. The labels are not part of the mathematical content of the equation; they are meta-mathematical annotations, and therefore should be considered to be in the meta-mathematical language, which is Hebrew. Labels should reasonably be stated after the equation has been stated. In Hebrew "after" is "to the left of".

  3. It is illuminating to consider how equation labels were placed in Hebrew textbooks predating the existence, or widespread use, of LaTeX. Following are photos of pages from four different such textbooks by four different authors and published in three different publishing houses. The books date from the 70s (the first two), the late 80s (the third), and the early aughts (the fourth). The first two books were typeset with a typewriter together with handwriting. The other two were typeset by customized proprietary typesetting software. In all four cases the equation numbers appear along the left margin.

Hebrew textbook from an unknown time

Hebrew textbook from the mid 70s

Hebrew textbook from the late 80s

Hebrew textbook from the early 00s

Now the important caveat I alluded to above. Ever since the use of LaTeX became widespread, Hebrew textbooks have begun numbering the equations in the right margin. Has this been done out of deliberate, justifiable rationale, or simply by a mindless, or helpless, drift in the current of the available LaTeX implementations? At any rate, since this is the state of affairs, I think the ideal thing would be to allow the user a way to specify their choice: whether they prefer the equation numbers along the left or right margin, as well as, possibly, the side they prefer the equation and theorem labels to appear when the showlabels package is used.


My question is: how can the corrections and modifications suggested above be made?

Evan Aad
  • 11,066
  • 2
    when using non-latin script you should normally use harfbuzz, so \babelfont{rm}[Renderer=Harfbuzz]{FreeSans}. That will correct the parenthese. The class option leqno puts equation number on the left. Apart from this: there are to my knowledge currently only two people working on bidi for latex, the author of bidi (used with xelatex) and the author of babel. So if you want some improvement here you shouldn't rant about the current state but accept that you will have to do own research. Check e.g. questions for arabic and also the babel issues and its documentation. – Ulrike Fischer Nov 17 '22 at 14:51
  • @UlrikeFischer Double thanks. The Harfbuzz option solves the parentheses problem, as you pointed out. It does not solve the braces problem, though. The leqno option left-justifies the equation numbers, as you pointed out. But when they are so justified, the labels are positioned to their right, i.e. inside the text area; they should be placed inside the margin. – Evan Aad Nov 17 '22 at 16:40
  • The following post is relevant to the placement of the labels in the margin when leqno is in effect: https://tex.stackexchange.com/a/585056 – Evan Aad Nov 17 '22 at 17:21
  • The showlabels option inline places the labels in the left margin (sort of) when the leqno class option is specified. – Evan Aad Nov 17 '22 at 17:31
  • 2
    amsmath is a very complex beast, which formats labels in several ways and, furthermore, modifies the internal definitions dynamically. Patching it for bidi texts is far from trivial. Several bugs in luatex, now apparently fixed, made things ever harder. As to the default position (left or right), I revised a lot of Hebrew books in the (now extinct) z-lib, and I didn’t find a clear rule. Anyway, leqno changes its position. Feel free to open an issue. Right now I’m very busy, but next week I’ll resume the work on babel. – Javier Bezos Nov 17 '22 at 18:51
  • @JavierBezos I've opened two bug reports: https://github.com/latex3/babel/issues/199 for the wrongly facing braces, and https://github.com/latex3/babel/issues/200 for the misplacement of equation labels on the page. – Evan Aad Nov 18 '22 at 06:53

0 Answers0