From 938ef8c2b6e780614b672331a704d9049d0edad8 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 2 Feb 2012 01:06:07 +0100 Subject: first chapter of manual --- .../third/cyrillicnumbers/cyrillicnumbers.tex | 182 ++++++++++++++++++--- .../third/cyrillicnumbers/cyrillicnumbers.lua | 15 +- .../third/cyrillicnumbers/t-cyrillicnumbers.mkiv | 9 +- 3 files changed, 174 insertions(+), 32 deletions(-) diff --git a/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex b/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex index 98f4741..3206522 100644 --- a/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex +++ b/doc/context/third/cyrillicnumbers/cyrillicnumbers.tex @@ -3,6 +3,12 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usemodule[cyrillicnumbers] +\definecyrnum[normaltextcyrnum][ + command=\oldrussian, + dots=no, + titlo=no, +] + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Letterspacing / emphases % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -88,18 +94,24 @@ \definefontfeature [kerning] [kern=yes]% -\usetypescript [computer-modern-unicode] -\def\russian#1{\begingroup\language[ru]\setupbodyfont[computer-modern-unicode]#1\endgroup} - \starttypescript [serif] [bukyvede] % \setups [font:fallback:serif] \definefontsynonym [Serif] [name:Bukyvede] [features=default] \definefontsynonym [SerifItalic] [name:Bukyvede-Italic] [features=default] \stoptypescript + \usetypescript [bukyvede] \definetypeface [vintagecyrillic] [rm] [serif] [bukyvede] [default] [encoding=ec] +\usetypescriptfile [type-gfsbodoni.mkiv] +\usetypescript [gfs-bodoni] +\usetypescriptfile [type-imp-computer-modern-unicode.mkiv] +\usetypescript [computer-modern-unicode] + +\def\russian#1{\begingroup\language[ru]\setupbodyfont[computer-modern-unicode]#1\endgroup} + \def\oldrussian#1{\begingroup\language[ru]\setupbodyfont[vintagecyrillic]#1\endgroup} +\def\greek #1{\begingroup\language[agr]\setupbodyfont[computer-modern-unicode]#1\endgroup} \usetypescript [modern] \setupbodyfont [modern] @@ -109,12 +121,6 @@ \usetypescript [serif] [hz] [highquality] \setupalign [hanging,hz] -\setupbodyfontenvironment [default] [12pt] [interlinespace=15pt] -\setupbodyfontenvironment [default] [11pt] [interlinespace=13pt] -\setupbodyfontenvironment [default] [10pt] [interlinespace=12pt] -\setupbodyfontenvironment [default] [9pt] [interlinespace=11pt] -\setupbodyfontenvironment [default] [8pt] [interlinespace=10pt] - \setupbodyfontenvironment [default] [em=italic] \def\quote#1{\bgroup\italic#1\egroup} @@ -349,15 +355,15 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \setupcaptions[ -% location=bottom, -% headstyle=\tfx\italic, -% way=bytext, -% prefixsegments=none, -% style={\setupinterlinespace[9pt]\tfx}, -% ] -% -% \setupcaption [figure] [way=bytext] +\setupcaptions[ + location=bottom, + headstyle=\tfx\italic, + way=bytext, + prefixsegments=none, + style={\setupinterlinespace[9pt]\tfx}, +] + +\setupcaption [figure] [way=bytext] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Bibliography % @@ -460,6 +466,21 @@ \setupheadertexts [] [] [] [] \setuppagenumbering [state=stop,location=] +\startbuffer[showcase1] + local tab = { } + tab[#tab+1] = [[\placetable[right,3*hang][numval]{Number values of the Cyrillic alphabet}{\starttabulate[|r|]]..string.rep("l|", 9).."]" + tab[#tab+1] = [[\NR\NC $n$]] + for i=1, 9 do tab[#tab+1] = [[\NC $]]..i.."$" end + tab[#tab+1] = [[\NC\NR\HL\NC $n · 10^0$]] + for i=1, 9 do tab[#tab+1] = [[\NC\normaltextcyrnum{]]..i.."}" end + tab[#tab+1] = [[\NC\NR\NC $n · 10^1$]] + for i=10, 90, 10 do tab[#tab+1] = [[\NC\normaltextcyrnum{]]..i.."}" end + tab[#tab+1] = [[\NC\NR\NC $n · 10^2$]] + for i=100, 900, 100 do tab[#tab+1] = [[\NC\normaltextcyrnum{]]..i.."}" end + tab[#tab+1] = [[\stoptabulate\blank[force,2*big]}]] + context(table.concat(tab)) +\stopbuffer + \starttext \startfrontmatter @@ -553,11 +574,105 @@ [{\headertextformat\pagenumber}] [{\headertextformat\getmarking[chapter]}] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\chapter{Introduction} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\chapter{Functionality} +\startchapter[title=Introduction] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The \CONTEXT\ format comes with a collection of conversion +routines for different number systems that are specified in the +files \type{core-con.mkiv} and \type{core-con.lua}. +\te{Cyrillic numerals}, however, are not part of this collection. +The aim of the module at hand is to provide means of handling +Cyrillic numbers and make them seamlessly integrate with the +existing interface for number conversion. + +If you are familiar with Cyrillic numbers, you might choose to +skip the rest of this section and instead continue in medias res +with the description on the module’s usage in the section on +\about[functionality]. + +\ctxluabuffer[showcase1] +\indentation The Cyrillic system, like the alphabet +it is based on, originated from the Greek numerals and thus +continues many features of the latter.\footnote{% + Thorough examinations of how Cyrillic numbers were used in + praxi are hard to find. + The best that the couple of bookshelfs dedicated to grammar in + a local department of Slavonic languages has to offer appears + to be \ctay{zolobov}. + Another work, \ctay{trunte}, although it follows a less + descriptive but rather instructional approach, deserves + mentioning as well. +} +As with the Roman number system, there are no genuine glyphs +reserved for numerals, instead numbers are represented by strings +of letters from the ordinary alphabet, organized in a peculiar +way. +The first nine digits, in ascending order, are: +\dorecurse{9}{\ifnum\recurselevel=9 and \fi% + “\normaltextcyrnum{\recurselevel}”% + \ifnum\recurselevel<9, \fi}. +As you might have noticed, this series does not correspond to the +first nine glyphs of the Cyrillic alphabet +(\oldrussian{а б в г д е ж ѕ з}), but rather to the order of the +original Greek letters from which they were derived +(\greek{α β γ δ ε ϛ ζ η θ}, with the character \greek{ϛ} at +position №~6 representing “stigma”). +The inherited order of numerical values was kept, essentially +trading backward compatibility for simplicity. +The two other sets of letters that represent multiples of ten and +hundred are listed in \in{Table}[numval]. +The digits are written in descending order, beginning with the +most significant one. +The numbers from 11 to 19 follow a different rule for their order +mimicks the spoken language, which means that the \te{less} +significant digit \te{precedes} the more significant one +(\dostepwiserecurse{11}{18}{1}{\normaltextcyrnum{\recurselevel}, }% +\normaltextcyrnum{19}). +There are no glyphs to represent zeros, so they are simply left +out. +For example, in the Cyrillic system the number 42 is written as +\normaltextcyrnum{42}; the lack of a distinct zero sign causes +402 to have \te{two} digits as well, but the character +representing the digit 4 gets chosen from the hundreds set: +\normaltextcyrnum{402}. + +% above 10^3 +The rules so far don’t allow for numbers above 999. +To compensate for the lack of additional letters, greater numbers +are represented by the same glyphs (their value being padded by +1000). +There are two ways to avoid confusion: Each digit may be prefixed +with a special character, the thousands sign \oldrussian{҂}. +That way, 42 is still written \normaltextcyrnum{42}, but 42~000 +becomes \normaltextcyrnum{42000}, and their sum +\normaltextcyrnum{42042}. +But if numbers become bigger, the high digits can take +alternative ornate forms: +\space\normaltextcyrnum[preferhundredk=yes]{100000} -- instead of +\normaltextcyrnum{100000} -- for 100~000, and +\space\normaltextcyrnum{1000000} for 1~000~000. + +% dots, titlo +In an environment where punctuation was at best minimal and +interword spacing a luxury, numbers of this kind tend to be +confused with text. +Therefore, a Cyrillic number can have additional markers. +\te{Dots} are used as delimiters before and after a number: +\normaltextcyrnum[dots=yes]{42}. +Additionally, a number may be indicated by the \te{titlo}, which +may span its whole length or just parts of it: +\normaltextcyrnum[titlo=mp]{42}. + +The Cyrillic number module combines all the above mentioned +aspects into one handy command generator, relying on Lua for the +conversion routine and \METAPOST\ for the titlo placement. +With all options in one place, it is trivial to create and +maintain different conversion settings for different purposes. + +\stopchapter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\startchapter[reference=functionality,title=Functionality] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Default Command} \showsetup{cyrnum} @@ -569,14 +684,26 @@ \showsetup{setupcyrnum} \showsetup{definecyrnum} +\stopchapter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\startchapter[reference=usage,title=Usage and Precautions] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \section{Counters} +\section{The Titlo} + +\section{Font Issues} + +\stopchapter + \stopbodymatter \startbackmatter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\chapter{License} +\startchapter[title=License] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright 2012 \te{Philipp Gesang}. All rights reserved. @@ -616,13 +743,18 @@ conditions are met: \stopalignment \endgroup +\stopchapter -\chapter{References} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\startchapter[title=References] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startbibindent \placepublications[criterium=all] \stopbibindent +\stopchapter + \stopbackmatter \stoptext diff --git a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua index f8f745b..cec98c7 100644 --- a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua +++ b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua @@ -214,7 +214,20 @@ local titlofuncs = { result[#result+1] = stop_titlo return result end, - no = function (x) return x end, + no = function (list) + local result = { } + for i=#list, 1, -1 do + local char, digit, before, after = list[i][1], list[i][2], list[i][3], list[i][4] + if before then + result[#result+1] = before + end + result[#result+1] = char + if after then + result[#result+1] = after + end + end + return result + end, } --[[ldx-- diff --git a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv index 8321dac..c13b00d 100644 --- a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv +++ b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv @@ -383,12 +383,8 @@ } \def\dodo_cyrnum[#1]{% - % \iffirstargument - % \doifassignmentelse{#1}{\setupcyrnum[\currentcyrnum][#1]}\relax - \setupcyrnum[\currentcyrnum][#1]% - % \else - % \setupcyrnum - % \fi + \begingroup% + \setupcyrnum[\currentcyrnum][#1]% \cyrnumparameter{command}\begingroup% \dododo_cyrnum% } @@ -396,6 +392,7 @@ \def\dododo_cyrnum#1{% \ctxcommand{cyrillicnumerals(\number#1)}% \endgroup% + \endgroup% } %D \macros -- cgit v1.2.3