diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-01 13:39:31 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-01 13:39:31 +0200 |
commit | c44a9d2f89620e439f335029689e7f0dff9516b7 (patch) | |
tree | 1062a464cb13362d82598c41c437ab1c7eb4f236 /doc/context/sources/general/manuals/languages/languages-numbering.tex | |
parent | 665f9095475ffcd1c8750546727c75e5486a266f (diff) | |
download | context-c44a9d2f89620e439f335029689e7f0dff9516b7.tar.gz |
2016-08-01 13:07:00
Diffstat (limited to 'doc/context/sources/general/manuals/languages/languages-numbering.tex')
-rw-r--r-- | doc/context/sources/general/manuals/languages/languages-numbering.tex | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/doc/context/sources/general/manuals/languages/languages-numbering.tex b/doc/context/sources/general/manuals/languages/languages-numbering.tex new file mode 100644 index 000000000..3464826df --- /dev/null +++ b/doc/context/sources/general/manuals/languages/languages-numbering.tex @@ -0,0 +1,307 @@ +% language=uk + +\startcomponent languages-numbering + +\environment languages-environment + +\startchapter[title=Numbering][color=darkgreen] + +\startsection[title=Introduction] + +Numbering is complex and in \CONTEXT\ it's not easy either. This is because we +not only have 1, 2, 3 \unknown\ but also sub numbers like 1a, 1b, 1ic \unknown\ +or 1.a, 1.b, 1.c \unknown\ There can be many levels, different separators, final +symbols. As we're talking languages we only discuss conversion here: the +mechanism that turns a number in for instance a letter. It happens that the +mapping from a number onto a letter is language dependent. The next lines show +how English, Spanish and Slovenian numbers: + +\blank +\startpacked +\startcolor[maincolor] +\dontleavehmode + {\ttbf\mainlanguage[en]\dorecurse{28} + {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par +\dontleavehmode + {\ttbf\mainlanguage[es]\dorecurse{28} + {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par +\dontleavehmode + {\ttbf\mainlanguage[sl]\dorecurse{28} + {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par +\stopcolor +\stoppacked +\blank + +You convert a number into a letter with: + +\starttyping +\convertnumber{alphabetic}{15} +\stoptyping + +There is also \type {\uconvertnumber} which does not expand unless typesetting +is going on. Normally you don't need to bother about this. + +The \type {alphabetic} converter adapts to the current main language. When a +language has no special alphabet, the regular 26 characters are used. + +A converter can also convert to a roman numeral, a language specific ordered +list, a day or month, an ordinal string and again there can be a language +specific conversion. The general conversion macro takes a conversion name and +a number. When a conversion can be set (for instance in an itemized list, or in +section numbering) you can use these names. You can define additional +converters if needed, as long as the converter can handle a number. + +\starttyping +\defineconversion [alphabetic] [\alphabeticnumerals] +\stoptyping + +Here \type {\alphabeticnumerals} is a converter. If you look into the source of +\CONTEXT\ you will see that many converters are calling out to \LUA, where we +have implemented those specific conversions. The following table has long and +short names. The short one are historic. + +\starttabulate +\FL +\NC month \NC \type {\monthlong} \NC \NR +\NC month:mnem \NC \type {\monthshort} \NC \NR +\ML +\NC character \NC \type {\character} \NC \NR +\NC Character \NC \type {\Character} \NC \NR +\NC characters \NC \type {\characters} \NC \NR +\NC Characters \NC \type {\Characters} \NC \NR +\ML +\NC AK \NC \type {\smallcappedcharacters} \NC \NR +\NC KA \NC \type {\smallcappedcharacters} \NC \NR +\ML +\NC alphabetic a \NC \type {\alphabeticnumerals} \NC \NR +\NC Alphabetic A \NC \type {\Alphabeticnumerals} \NC \NR +\ML +\NC number numbers n \NC \type {\numbers} \NC \NR +\NC Numbers N \NC \type {\Numbers} \NC \NR +\NC mediaeval m \NC \type {\mediaeval} \NC \NR +\ML +\NC word words \NC \type {\verbosenumber} \NC \NR +\NC Word Words \NC \type {\VerboseNumber} \NC \NR +\ML +\NC ordinal \NC \type {\ordinalnumber} \NC \NR +\NC Ordinal \NC \type {\Ordinalnumber} \NC \NR +\ML +\NC romannumerals i r \NC \type {\romannumerals} \NC \NR +\NC Romannumerals I R \NC \type {\Romannumerals} \NC \NR +\ML +\NC o \NC \type {\oldstylenumerals} \NC \NR +\NC O \NC \type {\oldstylenumerals} \NC \NR +\NC or \NC \type {\oldstyleromannumerals} \NC \NR +\ML +\NC KR \NC \type {\smallcappedromannumerals} \NC \NR +\NC RK \NC \type {\smallcappedromannumerals} \NC \NR +\ML +\NC greek g \NC \type {\greeknumerals} \NC \NR +\NC Greek G \NC \type {\Greeknumerals} \NC \NR +\NC mathgreek \NC \type {\mathgreek} \NC \NR +\ML +\NC abjadnumerals \NC \type {\abjadnumerals} \NC \NR +\NC abjadnodotnumerals \NC \type {\abjadnodotnumerals} \NC \NR +\NC abjadnaivenumerals \NC \type {\abjadnaivenumerals} \NC \NR +\ML +\NC thainumerals \NC \type {\thainumerals} \NC \NR +\NC devanagarinumerals \NC \type {\devanagarinumerals} \NC \NR +\NC gurmurkhinumerals \NC \type {\gurmurkhinumerals} \NC \NR +\NC gujaratinumerals \NC \type {\gujaratinumerals} \NC \NR +\NC tibetannumerals \NC \type {\tibetannumerals} \NC \NR +\NC greeknumerals \NC \type {\greeknumerals} \NC \NR +\NC Greeknumerals \NC \type {\Greeknumerals} \NC \NR +\NC arabicnumerals \NC \type {\arabicnumerals} \NC \NR +\NC persiannumerals \NC \type {\persiannumerals} \NC \NR +\NC arabicexnumerals \NC \type {\arabicexnumerals} \NC \NR +\NC arabicdecimals \NC \type {\arabicdecimals} \NC \NR +\NC persiandecimals \NC \type {\persiandecimals} \NC \NR +\ML +\NC koreannumerals kr \NC \type {\koreannumerals} \NC \NR +\NC koreanparenthesisnumerals kr-p \NC \type {\koreanparenthesisnumerals} \NC \NR +\NC koreancirclenumerals kr-c \NC \type {\koreancirclenumerals} \NC \NR +\ML +\NC chinesenumerals cn \NC \type {\chinesenumerals} \NC \NR +\NC chinesecapnumerals cn-c \NC \type {\chinesecapnumerals} \NC \NR +\NC chineseallnumerals cn-a \NC \type {\chineseallnumerals} \NC \NR +\ML +\NC sloveniannumerals \NC \type {\sloveniannumerals} \NC \NR +\NC slovenianNumerals \NC \type {\slovenianNumerals} \NC \NR +\ML +\NC spanishnumerals \NC \type {\spanishnumerals} \NC \NR +\NC spanishNumerals \NC \type {\spanishNumerals} \NC \NR +\LR +\stoptabulate + +The \type {alphabetic} and \type {Alphabetic} converters adapt to slovenian and +spanish as do their small capped alternatives. There are more general helpers for it +too: + +\starttyping +\languagecharacters{number} +\languageCharacters{number} +\stoptyping + +Also language related is the \type {\continuednumber} macro. Here we see an +application: + +\startbuffer +1 \continuednumber{1} +1, 2 \continuednumber{2} +1, 2, 3 \continuednumber{3} +\stopbuffer + +\typebuffer + +What renders as: + +\startlines[color=maincolor] +\getbuffer +\stoplines + +Such a macro is typically used in combination with counters ant it just typesets +a label text depending on the valu ebeing non|-|zero. + +\startbuffer +\setuplabeltext[en][continued={and so on}] +1, 2, 3 \continuednumber{3} +1, 2, 3 \convertnumber{continued}{3} +\stopbuffer + +\typebuffer + +This gives: + +\startlines[color=maincolor] +\getbuffer +\stoplines + +In the rare case that you want to check if a conversion is defined you can use + +\starttyping +\doifelseconversiondefined{name}{true}{false} +\stoptyping + +So, + +\startbuffer +\doifelseconversiondefined{characters}{we can convert}{forget about it} +\stopbuffer + +\typebuffer + +Gives: + +\startlines[color=maincolor] +\getbuffer +\stoplines + +There are also some non language related converters that we mention here for +completeness: + +\blank +\type {set 0}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 0}{#1} }\stopcolor\par +\type {set 1}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 1}{#1} }\stopcolor\par +\type {set 2}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 2}{#1} }\stopcolor\par +\type {set 3}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 3}{#1} }\stopcolor\par +\blank + +When a set overruns we start again at the first element. + +The ordinal converter produces output like \color [maincolor] {\convertnumber +{ordinal}{123}} and \color [maincolor] {\convertnumber {ordinal}{654}}. The +corresponding string renderer is \type {\highordinalstr}. + +% quite limited currently op not documented here: +% +% \wordtonumber{two}{3} +% \wordtonumber{fivethousand}{unknown} + +\stopsection + +\startsection[title=Dates] + +Dates are also language dependent. The following macros take a number and return +the name of the month or day. + +\starttabulate +\NC \type {\monthlong } \NC \monthlong {10} \NC \NR +\NC \type {\monthshort} \NC \monthshort{10} \NC \NR +\NC \type {\MONTH } \NC \MONTH {10} \NC \NR +\NC \type {\MONTHLONG } \NC \MONTHLONG {10} \NC \NR +\NC \type {\MONTHSHORT} \NC \MONTHSHORT{10} \NC \NR +\NC \type {\weekday } \NC \weekday {5} \NC \NR +\NC \type {\WEEKDAY } \NC \WEEKDAY {5} \NC \NR +\stoptabulate + +The current date can be typeset with \type {\currentdate} and a +specific date with \type {\date}, for instance: + +\startbuffer +\currentdate[weekday,day,month,year] +\currentdate[WEEKDAY,day,MONTH,year] +\date[d=12,m=12,y=1998][weekday] +\date[d=12,m=12,y=1998] +\stopbuffer + +\typebuffer + +\startlines[color=maincolor] +\getbuffer +\stoplines + +Possible elements of the specification are: + +\starttabulate +\FL +\NC + ord \NC ordinal suffix \NC \NR +\NC ++ highord \NC high ordinal suffix \NC \NR +\ML +\NC mnem: \NC mnemonic prefix \NC \NR +\ML +\NC Y y year \NC year 4 digits \NC \NR +\NC yy \NC year 2 digits \NC \NR +\ML +\NC M \NC month 1 or 2 digits \NC \NR +\NC mm \NC month 2 digits \NC \NR +\ML +\NC D \NC day 1 or 2 digits \NC \NR +\NC dd \NC day 2 digits \NC \NR +\ML +\NC W \NC 1 digit \NC \NR +\ML +\NC month m \NC language dependent (can be mnemonic) \NC \NR +\NC day d \NC language dependent \NC \NR +\NC weekday w \NC language dependent \NC \NR +\ML +\NC MONTH \NC month uppercased \NC \NR +\NC WEEKDAY \NC weekday uppercased \NC \NR +\ML +\NC referral \NC YYYMMDD \NC \NR +\ML +\NC space \\ \NC space \NC \NR +\NC <word> \NC word \NC \NR +\LL +\stoptabulate + +There are also some converters built in (more can be added), for instance: + +\startbuffer +The current {\em gregorian} date \currentdate [month, day, {, }, year] is +in {\em jalali} \currentdate [jalali:to, month, day, {, }, year] but we +can also as a specific one, so {\em jalali} \date [y=1395, m=4, d=18] +[month, day, {, }, year] is {\em gregorian} \date [y=1395, m=4, d=18] +[jalali:from, month, day, {, }, year]. +\stopbuffer + +\typebuffer \startnarrower \getbuffer \stopnarrower + +\stopsection + +% \startsection[title=Counters] +% +% \stopsection + +\stopchapter + +\stopcomponent |