Changes

Jump to navigation Jump to search
2,405 bytes added ,  03:02, 18 August 2016
m
Persian \digits
Here we collect several tips and tricks for dealing with right-to-left (RTL) texts as well as BiDi (bidirectional) texts. The large number of hooks in different commands makes it possible to use CONTEXT's support for such documents. However, there are limitations and/or bugs, as well. Everything here is tested in MkIV and we recommend that you try one of the most recent versions since certain bugs are fixed and features are added only in the beta. All the credit should go to Hans, Wolfgang and others who respond to questions on the mailing list.
== Basics ==
<texcode>
\setuppagenumber[numberconversion=persiandecimals]
</texcode>
 
=== Indic numerals in math mode ===
In Persian (and perhaps Arabic and Hebrew) we often want to have Indic numerals in math formulas. We can use a fallback mechanism to substitute all Latin digits by the Indic ones.
 
<context source=yes mode=mkiv text="This produces:">
\resetfontfallback [mathdigits]
% use arabicindic for standard Arabic (Indic) digits
\definefontfallback [mathdigits] [dejavusansmono] [digitsextendedarabicindic] [check=yes,force=yes,offset=digitsnormal]
\definefontfallback [mathdigits] [dejavusansmonobold] [digitsextendedarabicindic] [check=yes,force=yes,offset=digitsbold]
\definefontsynonym[MathRoman][file:xits-math.otf][features=math\mathsizesuffix,goodies=xits-math,fallbacks=mathdigits]
\setupbodyfont[dejavu]
\starttext
$3+2=5 \quad \bf 3+2=5$ \endgraf
\stoptext
</context>
 
<em>This works in the beta but not on the stable here.</em>
 
By (re)defining certain macros, we can use commands like {{cmd|digits}} to properly translate decimal points, thousand separators, etc. to their Arabic/Persian equivalents.
 
<texcode>
\def\digitsperiodsymbol{٫}
\digits{1.5}
</texcode>
<em>The alignment of the second line is not right here but it works fine on my machine. Maybe the garden's CONTEXT version is old.</em>
Using {{code|1=alternative=left}} or {{code|1=alternative=right}} produces almost fine results in RTL but the placement of head text on the right-hand side adds some extra space. To avoid this, one can set {{code|1=width=fit}}. Using {{code|1=alternative=top}} places the head on the left-hand side even in RTL mode. This can be fixed via setting {{code|headalign}} (if the text is itself RTL).
In any case, the worst result comes from setting {{code|hang}} which places the hanging on the incorrect side (left for RTL) and pushes the head text into the margin on the correct side (right in RTL)!
\stopcolumns
</texcode>
 
<em>There is currently a bug that leads to incorrect section numbering inside RTL columns.</em>
 
=== Tables ===
 
CONTEXT has several mechanisms for typesetting tables: see [[Tables_Overview]]. Natural tables are the recommended construct, but they are somewhat verbose. It's easier for quick small tables to use the older macros adapted (and enhanced) from the TaBlE package. This is not actively developed, so we do not hope for new RTL features in particular.
 
Using them on their own ignores the paragraph direction and sets an LTR table. However, when wrapped in {{cmd|leftaligned}} or its friends, we get RTL/LTR tables depending on the paragraph direction.
 
<context source=yes mode=mkiv text="This produces:">
\usemodule[simplefonts]
\setmainfont[dejavusans][features=arabic,range=arabic]
\setupdirections[bidi=global,method=one]
\setupalign[r2l]
\starttext
\midaligned{\starttable[|c|c|]
\NC \REF[cB]{ماه} \NC \REF[cB]{تعداد روز} \NC \AR
\NC ژانویه \NC ۳۱ \NC \AR
\NC فوریه \NC ۲۸ \NC \AR
\NC مارس \NC ۳۱ \NC \AR
\stoptable}
\stoptext
</context>
== TODO ==
Here are some of the things to be added:
* Math mode Hindi digits* RTL tablesNatural tabels
* Float numbering
* Margin notes
25

edits

Navigation menu