Skip
repetitive navigational links
L-Soft  -  Home of  the  LISTSERV  mailing list  manager LISTSERV(R) 14.5
Skip repetitive navigational links
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2003)Back to main IVRITEX pageJoin or leave IVRITEXReplyPost a new messageSearchProportional fontNon-proportional fontLog in
Date:         Wed, 21 May 2003 19:05:12 +0300
Reply-To:     Hebrew TeX list <[log in to unmask]>
Sender:       Hebrew TeX list <[log in to unmask]>
From:         Ron Artstein <[log in to unmask]>
Subject:      Hebrew numbers in TeX
Content-Type: TEXT/PLAIN; charset=US-ASCII

Dear Hebrew users, I've written some code that attempts to clean up the \alph, \hebr and \gim mess in the Hebrew babel. The update is appended below, but before it is officially released I need some community input on the following two points. 1. Hebrew numbers can be written without apostrophes (qof-nun), with apostrophes (qof-"-nun), and with apostrophes and final letters (qof-"-finalnun). The package allows printing with all three options. I offer the following commands: \alph prints a counter without apostrophes \Alph prints a counter with apostrophes \Alphfinal prints a counter with apostrophes and final letters Are these commands intuitive? My rationale is that in a Hebrew environment, \alph should print Hebrew letters (just like in Greek babel it prints with Greek letters). If you need Latin labels in a Hebrew text then switch locally to Latin, just like you do if you need a Latin word (or Greek, or Finnish, or whatever). Since Hebrew has no uppercase letters, we can use \Alph for something else, namely for apostrophes. I chose a nonstandard name for printing with final letters because I believe it's the least useful command---as far as I know, this is only used in year designators. The package also offers the commands \hebrewnumeral, \Hebrewnumeral and \Hebrewnumeralfinal for printing a Hebrew number from a decimal input rather than a counter (on par with \greeknumeral and \Greeknumeral from the Greek babel, which print Greek gimatrya from a decimal input). The plan is to eliminate the commands \hebr and \gim, but the current test version doesn't touch them. 2. Year designators are written with final letters: the Hebrew year corresponding to AD 1990 is tav-shin-"-finalnun. Now, what is the convention for year designators when no hundreds are present? The Hebrew year corresponding to AD 1290, is it nun-' (or he-'-nun-') or is it finalnun-' (he-'-finalnun-')? Presently, hebcal.sty provides final letters in such a context, while my aesthetic judgment prefers initial letters. However, my aesthetics do not count: there must be a convention, I just don't know what it is. Does anyone know? The code is appended below. Just copy the bottom part of the message to a file foo.sty and call it with \usepackage{foo}, together with Hebrew babel \usepackage[hebrew]{babel}. The package employs a trick in order to prevent the present hebrew.ldf from overriding its definitions, and I don't know if it will work when additional languages are used. I tried it with the hebrew.ldf file dated [2002/12/26 v2.3f]. Comments, bug reports etc. as well as answers to my two questions above will be very much appreciated. Cheers, -Ron. [log in to unmask] %%%%%%%%%%%%%%%%%%%%% BEGIN STYLE FILE %%%%%%%%%%%%%%%%%%%%% % LaTeX style file to print correct Hebrew numbers % Ron Artstein [log in to unmask] 2003/05/21 % We want both a user command to print a Hebrew number from a % decimal input, and a command that will print the value of a % counter as a Hebrew number. The latter will be defined using % the former. % Hebrew numbers can be written in a number of 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. We provide two flags to set them. \newif\if@gim@apost % whether we print apostrophes \newif\if@gim@final % whether we use final or initial letters % The styles must always be specified locally: if we allowed a % counter (or any other generated text) to depend on a global style % option then we would get inconsistencies, for instance page numbers % might appear in different styles if the default changed mid-way % through a document. % The user commands only allow three of the four possible flag % combinations (I do not know of a use that requires the combination % of final letters and no apostrophes). % Double braces are used in order to protect the values of \@tempcnta % and \@tempcntb, which are changed by the call to \@hebrew@numeral; % they also keep the flag assignments local (this is not important % because the global values are never used). \newcommand*{\hebrewnumeral}[1] % no apostrophe, no final letters {{\@gim@finalfalse\@gim@apostfalse\@hebrew@numeral{#1}}} \newcommand*{\Hebrewnumeral}[1] % apostrophe, no final letters {{\@gim@finalfalse\@gim@aposttrue\@hebrew@numeral{#1}}} \newcommand*{\Hebrewnumeralfinal}[1] % apostrophe, final letters {{\@gim@finaltrue\@gim@aposttrue\@hebrew@numeral{#1}}} % Counter-printing commands are based on the above commands. The % natural name for the counter-printing commands is \alph, because % Hebrew numerals are the only way to represent numbers with % Hebrew letters (kaf always means 20, never 11). Hebrew has no % uppercase letters, hence no need for the familiar meaning of \Alph; % we therefore define \alph to print counters as Hebrew numerals % without apostrophes, and \Alph to print with apostrophes (this % seems semi-intuitive to me; any better suggestions?). A third form, % \Alphfinal, is provided to print with apostrophes and final letters, % as is required for Hebrew year designators. For \alph and \Alph we % only need to redefine the internal commands \@alph and \@Alph; for % \Alphfinal we need both a wrapper and an internal command. % Note that \alph, without apostrophes, is already the appropriate % choice for the second-level enumerate label, so no redefinition of % \theenumii is required. LaTeX default class files specify \Alph for % the fourth-level enumerate level, this should probably be changed. % Also, the way labels get flushed left by default looks inappropriate % for Hebrew numerals, so we should redefine \labelenumii as well % as \labelenumiv (presently not implemented). % The counter printing commands are made robust, otherwise \theenumii % breaks (I'm not quite clear on why this happens). % The \beginR...\endR wrappers are hacks in order to make Hebrew page % number labels print in the correct direction. They should print % correctly without the wrappers, but at the moment they don't. % The \AtBeginDocument wrappers are hacks for testing, to prevent % the old (and wrong) defaults from hebrew.ldf from overriding the % new code. They should be removed when the code is incorporated % into babel. \AtBeginDocument{% \DeclareRobustCommand*{\@alph}[1]{\beginR\hebrewnumeral{#1}\endR}% } \AtBeginDocument{% \DeclareRobustCommand*{\@Alph}[1]{\beginR\Hebrewnumeral{#1}\endR}% } \def\Alphfinal#1{\expandafter\@Alphfinal\csname c@#1\endcsname} \DeclareRobustCommand*{\@Alphfinal}[1]{\beginR\Hebrewnumeralfinal{#1}\endR} % The placement of apostrophes: if the number consists of a single % letter then it is followed by a single apostrophe, and if the number % consists of more than one letter then a double apostrophe is % inserted before the last letter. % The approach of the hebcal.sty package is to first generate the % entire string, then check its length, and finally insert the % appropriate apostrophe in the correct place and typeset the % result. I feel that this approach is unnecessarily complicated, % so I provide a different algorithm. % We typeset the letters one at a time, keeping a flag that tells us % if any previous letters had been typeset. For each letter, we first % deduct its value from the total. Then, % => if there is no remainder then this is the last letter; we check % the flag to see if this is the only letter and print it with the % appropriate apostrophe; % => if there is a remainder then this is not the last letter; we % print without an apostrophe and set the `previous letter' flag. \newif\if@gim@prev % flag if a previous letter has been typeset % The command \gim@print prints a single Hebrew letter; % we first deduct the letter's value from \@tempcnta, % so \@tempcnta=0 if and only if this is the last letter. \newcommand*{\gim@print}[2]{% #2 is a letter, #1 is its value, % \@tempcnta holds the remainder \advance\@tempcnta by -#1\relax% deduct the value from the remainder \ifnum\@tempcnta=0% if this is the last letter % if there is a preceding letter, print "x if we print % apostrophes, x if we don't. \if@gim@prev\if@gim@apost"\fi#2% % otherwise, this is the only letter: force it to be non-final % (lone final letters are not allowed---is this the accepted % convention?) and print x' if we print apostrophes, x if we don't. \else{\@gim@finalfalse#2}\if@gim@apost'\fi\fi% % this is not the last letter: force it to be non-final, print, and % set the `previous letter' flag. \else{\@gim@finalfalse#2}\@gim@prevtrue\fi} % The command \gim@nomil typesets an integer between 0 and 999 (for 0 % it typesets nothing). The code has been modified from hebcal.sty % (add in appropriate credits---Boris Lavva and Michail Rozman ?). % \@tempcnta holds the remainder that needs to be typeset. At each % stage we check to see what is the highest valued letter that is % lower than \@tempcnta and call on \gim@print to deduct the value % and print the letter. % initialize: \@tempcnta holds the value, there is no previous letter. \newcommand*{\gim@nomil}[1]{\@tempcnta=#1\@gim@prevfalse % \hebtav needs to be repeated twice, since 800 = tav-tav. For some % unknown reason, \loop...\repeat doesn't work. \ifnum \@tempcnta > 399 \gim@print{400}{\hebtav}\fi \ifnum \@tempcnta > 399 \gim@print{400}{\hebtav}\fi \ifnum \@tempcnta > 299 \gim@print{300}{\hebshin}\fi \ifnum \@tempcnta > 199 \gim@print{200}{\hebresh}\fi \ifnum \@tempcnta > 99 \gim@print{100}{\hebqof}\fi % print the tens digit, using \ifcase instead of going through the % letters one by one the way we did with the hundreds. \@tempcntb=\@tempcnta\divide\@tempcntb by 10\relax% tens digit \ifcase\@tempcntb% print nothing if no tens \or% number between 10 and 19 \ifnum\@tempcnta = 16 \gim@print {9}{\hebtet}% tet-zayin \else\ifnum\@tempcnta = 15 \gim@print {9}{\hebtet}% tet-vav \else \gim@print{10}{\hebyod}% \fi % \@tempcnta = 15 \fi % \@tempcnta = 16 % print kaf or final kaf according to the current flag; % \gim@print will force a non-final letter in non-final % position and when it is the only letter \or\gim@print{20}{\if@gim@final\hebfinalkaf\else\hebkaf\fi}% \or\gim@print{30}{\heblamed}% \or\gim@print{40}{\if@gim@final\hebfinalmem\else\hebmem\fi}% \or\gim@print{50}{\if@gim@final\hebfinalnun\else\hebnun\fi}% \or\gim@print{60}{\hebsamekh}% \or\gim@print{70}{\hebayin}% \or\gim@print{80}{\if@gim@final\hebfinalpe\else\hebpe\fi}% \or\gim@print{90}{\if@gim@final\hebfinaltsadi\else\hebtsadi\fi}% \fi % print the ones digit \ifcase\@tempcnta% print nothing if no ones \or\gim@print{1}{\hebalef}% \or\gim@print{2}{\hebbet}% \or\gim@print{3}{\hebgimel}% \or\gim@print{4}{\hebdalet}% \or\gim@print{5}{\hebhe}% \or\gim@print{6}{\hebvav}% \or\gim@print{7}{\hebzayin}% \or\gim@print{8}{\hebhet}% \or\gim@print{9}{\hebtet}% \fi } % The command \@hebrew@numeral prints a Hebrew number. It can print % any number up to the maximum allowed by TeX, but I only know of % conventions for numbers up to 10999: the thousands are typeset as a % single digit (including yod for 10) followed by an apostrophe, and % the remainder is typeset in the conventional way. Higher numbers % will be typeset according to my own personal extension of the % accepted convention: the groups of thousands, millions, billions % are separated by apostrophes and typeset without apostrophes or % final letters; the remainder (under 1000) is typeset conventionally, % with the defaults for apostrophes and final letters. The algorithm % is recursive, but the maximum recursion depth is 4 because TeX % only allows numbers up to 2^31-1 = 2,147,483,647. % initialize: \@tempcnta holds the value, \@tempcntb used for % calculations \newcommand*{\@hebrew@numeral}[1]{\@tempcnta=#1\@tempcntb=#1\relax \divide\@tempcntb by 1000 % If we're under 1000, call \gim@nomil \ifnum\@tempcntb=0\gim@nomil\@tempcnta\relax % If we're above 1000 then force no-apostrophe and no-final letter % for the value above 1000, recur for the value above 1000, add an % apostrophe, and call \gim@nomil for the remainder \else{\@gim@apostfalse\@gim@finalfalse\@hebrew@numeral\@tempcntb}'% \multiply\@tempcntb by 1000\relax \advance\@tempcnta by -\@tempcntb\relax \gim@nomil\@tempcnta\relax \fi } \endinput %%%%%%%%%%%%%%%%%%%%%% END STYLE FILE %%%%%%%%%%%%%%%%%%%%%%


Back to: Top of message | Previous page | Main IVRITEX page

LISTSERV.TAU.AC.IL CataList email list search Powered by LISTSERV email list manager