4

A Short description of the problem

In a document whose main language is Hebrew, I'd like subequations to be numbered using the Hebrew, rather than the English, alphabet, and using right-to-left directionality, as in the following screenshot:

Hebrew subequations

This screenshot was obtained from the one in the next section, by cutting-and-pasting the numberings from the PDF resulting from the following code:

\documentclass{article}
\usepackage[bidi=basic,english,hebrew,provide=*]{babel}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSerif}
\usepackage{amsmath}
\begin{document}
$(\text{$1$א})$\par
$(\text{$1$ב})$\par
$(\text{$2$א})$\par
$(\text{$2$ב})$
\end{document}

A demonstration of the problem by way of a minimal working example

I saved the following LaTeX code in the file ~/Test.tex.

\documentclass{article}
\usepackage[bidi=basic,english,hebrew,provide=*]{babel}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSerif}
\usepackage{amsmath}
\begin{document}
\begin{subequations}
\begin{align}
a&=b+c\\
d&=e+f
\end{align}
\end{subequations}

\begin{subequations}
\begin{alignat}{2}
u&=v&&-w\\
x&=y&&-z
\end{alignat}
\end{subequations}
\end{document}

The code uses the babel package to configure the document's main language as Hebrew, and secondary language as English, and then, in the document's body, creates two sets of subequations: one that wraps about an align environment, and one that wraps about an alignat environment.

I then executed the following commands in the Terminal.

> cd ~
> lualatex Test

This resulted in the creation of the file ~/Test.pdf, which, when opened in a PDF viewer, displayed as follows. (I screenshot only the relevant part of the display.)

Subequations

As can be seen, the numberings use the English alphabet, and are directed from left-to-right in the sense that the numeric part of the numbering is to the left of the alphabetic part.

Question

How can I get subequation numbering to use the Hebrew alphabet? Moreover, the directionality of the numbering should be right-to-left, so as to print the alphabetic part of the numbering to the left of the numeric part of the numbering, as shown in the first screenshot of this post.

Remarks

I use the babel+LuaLaTex combo to typeset Hebrew documents. A solution that requires a different combo, e.g. polyglossia+XeLaTeX won't be considered a suitable solution.

1 Answer 1

4

You need to modify the code for subequations in amsmath. Here, I’ve created a new environment, called heSubequations, but you could redefine subequations instead.

\documentclass{article}
\usepackage[bidi=default,
            main=english,
            hebrew,
            provide+=*,
            layout=counters.sectioning.tabular
           ]{babel}
\usepackage{amsmath} % Also loaded by unicode-math.
\usepackage{unicode-math}

\defaultfontfeatures{ Renderer = HarfBuzz, Ligatures=TeX }
\babelfont{rm}[Ligatures=Common]{Libertinus Serif} % Or your fonts of choice.
\babelfont{sf}[Ligatures=Common]{Libertinus Sans}
\babelfont{tt}{Libertinus Mono}
\setmathfont{Libertinus Math}

% Based on the code for subequations in amsmath.
\makeatletter
\newenvironment{heSubequations}{%
  \refstepcounter{equation}%
  \protected@edef\theparentequation{\theequation}%
  \setcounter{parentequation}{\value{equation}}%
  \setcounter{equation}{0}%
  \def\theequation{%
    \foreignlanguage{hebrew}{%
      \theparentequation%
      \localecounter{letters}{equation}%
      }}%
  \ignorespaces
}{%
  \setcounter{equation}{\value{parentequation}}%
  \ignorespacesafterend
}
\makeatother

\begin{document}
\begin{heSubequations}
\begin{align}
a&=b+c\\
d&=e+f
\end{align}
\end{heSubequations}

\begin{heSubequations}
\begin{alignat}{2}
u&=v&&-w\\
x&=y&&-z
\end{alignat}
\end{heSubequations}
\end{document}

Libertinus sample

This code works in both XeLaTeX and LuaLaTeX, and should not break if you change the main language. You might want to change the bidi= option to basic in LuaTeX or bidi-r in XeLaTeX.

A simpler solution that might work for you in some cases is to set \alph to use Hebrew letters wherever Hebrew is the main language:

\babelprovide[import, main, alph=letters]{hebrew}

giving you the simpler code:

\documentclass{article}
\usepackage[bidi=basic,
            english,
            layout=counters.sectioning.tabular
           ]{babel}
\usepackage{amsmath} % Also loaded by unicode-math.
\usepackage{unicode-math}

\babelprovide[import, main, alph=letters]{hebrew}

\defaultfontfeatures{ Renderer = HarfBuzz, Ligatures=TeX }
\babelfont{rm}[Ligatures=Common]{Libertinus Serif} % Or your fonts of choice.
\babelfont{sf}[Ligatures=Common]{Libertinus Sans}
\babelfont{tt}{Libertinus Mono}
\setmathfont{Libertinus Math}

\begin{document}
\begin{subequations}
\begin{align}
a&=b+c\\
d&=e+f
\end{align}
\end{subequations}

\begin{subequations}
\begin{alignat}{2}
u&=v&&-w\\
x&=y&&-z
\end{alignat}
\end{subequations}
\end{document}

This works for me when I use bidi=basic in LuaLaTeX, but breaks in XeLaTeX or with bidi=default.

3
  • This might be a good fit with the tag forms in mathtools, but is not a feature of that package.
    – Davislor
    Commented Jan 22, 2023 at 9:30
  • Thank you. This is great. However, it doesn't interact quite well with cleveref. Should I open a new question for this issue, or would you like me to describe it here in the comments, or perhaps in an edit to my original post above?
    – Evan Aad
    Commented Jan 22, 2023 at 11:27
  • Never mind. Your second solution, with the alph=letters, works well with cleveref, so I'm satisfied.
    – Evan Aad
    Commented Jan 22, 2023 at 13:25

You must log in to answer this question.

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