latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
124 stars 34 forks source link

Adding the old Hebrew numerals styles to the new interface #249

Closed Udi-Fogiel closed 11 months ago

Udi-Fogiel commented 12 months ago

In the old .ldf file, babel provides three styles for Hebrew numerals. The first one mapped numbers to Hebrew letters according to Hebrew gematria, the second one adds geresh or gershayim, and the third also respect final letters.

Currently the .ini file provides only the first style, it would be nice to have the other styles as well. Recently I have re-implemented the code from the old .ldf file so that it would be expandable (even in an unprotected \edef etc.), the code is here.

I'm not sure how babel is using the information in the .ini file to redefine \alph or \Alph (where can I find the relevant code?), so I don't know how to incorporate this code to the package in a nice way.

jbezos commented 12 months ago

Thanks. Additive counters in ini files are defined in a declarative way (with four keys, ie, up to 9999), and they are fully expandable. A way to handle special cases is also provided, but I’m not sure it covers all possible cases. I’ll have a look at your code.

Counters are assigned to \alph and \Alph with \babelprovide. For example, with the only counter method provided currently (lettters):

\babelprovide[alph=letters]{hebrew}

For the code in babel defining and using the additive counters (somewhat tricky), search for \bbl@inikv@counters and \bbl@alphnumeral. A \tracingmacros2 can help 🙂.

jbezos commented 11 months ago

@Udi-Fogiel I think all these numerals are best treated separately with their own macros (this is also done for Greek), so if you don’t mind I’ll use your definitions for them. However, I’m not sure if the best option is consider them separate numeral systems or the same system with different options.

From what the babel-hebrew manual explains, there are four combinations, because there are two independent options:

Hebrew numbers can be written in various styles: with or without apostrophes, and with the letters kaf, mem, nun, pe, tsadi as either final or initial forms when they are the last letters in the sequence.

However, it also points out:

(I do not know of a use that requires the combination of final letters and no apostrophes.

Hence, 3 options. However, from what I see, there are even more options. For example, in cabalism the final forms have been sometimes separate “numbers” for 500-900. Also, it seems a double dot above a letter has been an alternative for thousands.

In case they are considered separate systems, I’d need names for them, like letters, letters.gershayim, letters.final.

What do you think?

jbezos commented 11 months ago

I’m closing the issue here (as such issue), because I’ve listed it in the Enhancements request project. This doesn’t mean the enhancement is rejected and the discussion closed, on the contrary.

jbezos commented 11 months ago

@Udi-Fogiel I think I’ve found a bug in you code: 2040 is rendered ב׳מ׳ instead of ב‘"מ. The problem is every three-digits chunk is treated as a separate number, so that what we get is 2000 immediately followed by 40.

Udi-Fogiel commented 11 months ago

@jbezos Sorry for the late reply.

@Udi-Fogiel I think all these numerals are best treated separately with their own macros (this is also done for Greek), so if you don’t mind I’ll use your definitions for them.

Of course! that is the reason I shared the link.

However, I’m not sure if the best option is consider them separate numeral systems or the same system with different options.

I'm not sure what is the difference, but I think that they should be independent. I, for example, am planing to use different systems for alph and Alph.

@Udi-Fogiel I think I’ve found a bug in you code: 2040 is rendered ב׳מ׳ instead of ב‘"מ. The problem is every three-digits chunk is treated as a separate number, so that what we get is 2000 immediately followed by 40.

Hmmm, I don't really know what is the correct output, I just re implemented the code from babel-hebrew. For example, with the following code I get 'ב'מ:

% !TeX TS-program = pdflatex

\documentclass{article}

\newcommand*\HeblatexEncoding{HE8}
\newcommand*\HeblatexEncodingFile{he8enc}
\usepackage[hebrew]{babel}

\begin{document}

\Hebrewnumeral{2040}

\end{document}

backwards compatibility was more important for me when I wrote the code, so I did not do any real research on the topic, other than comparing the results from the new and original code.

Do you happen to have a good source on the matter? If not, I can look for one at the university, or ask someone who is more authoritative.

jbezos commented 11 months ago

@Udi-Fogiel

I'm not sure what is the difference, but I think that they should be independent. I, for example, am planing to use different systems for alph and Alph.

👍 A good reason.

Hmmm, I don't really know what is the correct output, I just re implemented the code from babel-hebrew. For example, with the following code I get 'ב'מ: [...]

😮

Do you happen to have a good source on the matter? If not, I can look for one at the university, or ask someone who is more authoritative.

I mostly rely in the books by Ifrah (The Universal History Of Numbers) and Cajori (A history of mathematical notations). I double checked with the help of some web sites (eg, https://stevemorse.org/hebrew/romanhebrew.html), too, but if someone else can confirm it, much better.

jbezos commented 11 months ago

@Udi-Fogiel But—

https://he.wikipedia.org/wiki/%D7%94%27%D7%91%27

Udi-Fogiel commented 11 months ago

I did not find an obvious answer, so I'll approach the Hebrew academy. One thing I did noticed that I used quotation marks in my code and not geresh and gershayim. I think it was originally like that in the .ldf file because geresh and gershayim are not setup to work, regarding all the encoding stuff.

It is probably better to change it, as it is more accurate to use geresh and gershayim.

BTW, I would like to change a few things in babel-hebrew (adding utf8 encoding file, better handling of error messages and even maybe loading some of the culmus fonts), I've tried to contact Arthur Reutenauer as he is listed as the current maintainer, but did not succeed. Do you happen to know if I can take the maintenance of babel-hebrew upon myself? Sorry if this is not the correct place to ask that...

jbezos commented 11 months ago

If there is no obvious answer, there is something obvious to do — I’ll add the code (with some minor changes), because very likely, at least for years, the current output is correct, but with the possibility to add a switch in the future to change the behavior.

jbezos commented 11 months ago

As to babel-hebrew, please contact me using this form, so that I can send to you my private e-mail: https://latex3.github.io/babel/contact.html