In another post I asked how to create a new equation
-like environment called inequality
that will share equation
's counter. I received two good answers. However, these answers are not satisfactory under additional two conditions that I'm interested in. The conditions are:
- that the document's language be set to Hebrew via
babel
. - that the labels be shown.
I use the showlabels
package to show the labels, however I have no particular attachment to this package; if there's a solution to my problem that doesn't use showlabels
, it will be just as welcome. On the other hand, the babel
package is a hard requirement for a solution to be accepted.
Consider, for example, egreg's answer to my other post, to which I have added the \usepackage{showlabels}
command at the end of the preamble.
\documentclass{article}
%\usepackage[bidi=basic,hebrew,provide=*]{babel}
%\babelfont{rm}[Renderer=HarfBuzz]{FreeSerif}
%\babelfont{sf}[Renderer=HarfBuzz]{FreeSans}
%\babelfont{tt}[Renderer=HarfBuzz]{FreeMono}
\usepackage{cleveref}
\newenvironment{inequality}
{\crefalias{equation}{inequality}\begin{equation}}
{\end{equation}\ignorespacesafterend}
\crefname{inequality}{ineq.}{ineqs.}
\Crefname{inequality}{Ineq.}{Ineqs.}
\usepackage{showlabels}
\begin{document}
\begin{inequality}\label{q}
x \leq y
\end{inequality}
Behold~\cref{q}.
\begin{equation}\label{r}
x = y
\end{equation}
Behold~\cref{r}.
\end{document}
When this code is compiled with two calls to lualatex
, the following output is produced.
If now the document's language is set to Hebrew by uncommenting the four commented lines and recompiling, the resulting output is:
Note how the labels have disappeared! A similar outcome is observed with the solution given in BotonF's answer. (Bear in mind that Hebrew is a right-to-left language, and so the text's right-alignment is to be expected, and isn't a problem.)
Three other solutions have been considered, but none of them is adequate.
- Mico's solution suffers from the problem, which I described here, that in a Hebrew document the
inequality
environment's numbering is left aligned. - David's Carlisle's solution suffers from the problem that in a Hebrew document the label is positioned inside the equation instead of in the margin.
- Javier Bezos' solution works well in a Hebrew document, but fails in an English document, as I described in this question (which remains unanswered at the present time). I'd like a solution which will work well both in Hebrew documents and in English ones (as well as in bilingual documents).