[NTG-context] r2l alignment and linenumbering conflict?

talazem at fastmail.fm talazem at fastmail.fm
Mon Aug 3 15:54:32 CEST 2015


I am having problems with the directionality of numbers and mirrored characters (like parentheses). When using bidi, the numbers are inverted (5102 instead of 2015); with the explicit commands, the mirrored characters are inverted as well.

For reasons I think I understand, this is only happening in the text: the problem occurs with numbers in headings (chapters, etc.), and likewise in the main of the text. The digits of footnotes, linemargin numbers, and page numbers are correctly arranged.

I have learnt that if I add the option [numbercommand=\lefttoright] to \setuphead[section], I can get the digits in the section number to be in the right order. But this does not address the problem of other numbers in the text.

How do I solve this? I am happy to abandon the conveniences of bidi, as Idris suggests might be needed (see below), but it didn’t get any easier when trying to do it manually. See MWE below.

With thanks,
Talal

p.s. The Wiki page on "Arabic and Hebrew" is out of date, instructing the use of \setcharactermirroring[1] which is clearly deprecated now in favour of \setupdirections[bidi=global]. I am happy to update the wiki page once I get my head around things. Does anybody have an authoritative list of the various commands related to right-to-left, as well as what combinations are not needed (e.g. are \setupalign[r2l] and \righttoleft overlapping, or do they play different roles)?

========
%%% LANGUAGE AND FONTS
\mainlanguage[arabic]	
\definefontfamily [mainface] [rm] [ALM Fixed][range=arabic,features=arabic]	   
\setupbodyfont[mainface,12pt]

%\setupdirections[bidi=global]
\setupalign[r2l]
%\righttoleft

%% HEADINGS

\setuphead[chapter,section][
	conversion=myconversion,
%	numbercommand=\lefttoright % <-- toggle
	]
\setuplinenumbering[conversion=myconversion]
\setupnotations[footnote][numberconversion=myconversion]
\setupnotations[linenote][numberconversion=myconversion]
\setuppagenumber[numberconversion=myconversion]

\defineconversion
	[myconversion]
	[١,٢,٣,٤,٥,٦,٧,٨,٩,١٠,
	١١,١٢,١٣,١٤,١٥,١٦,١٧,١٨,١٩,٢٠,
	۲۱,۲۲,۲۳,۲٤,۲٥,۲٦,۲۷,۲۸,۲۹,۳۰,
	٣١,٣٢,٣٣,٣٤,٣٥,٣٦,٣٧,٣٨,٣٩,٤٠,
	٤١,٤٢,٤٣,٤٤,٤٥,٤٦,٤٧,٤٨,٤٩,٥٠,
	٥١,٥٢,٥٣,٥٤,٥٥,٥٦,٥٧,٥٨,٥٩,٦٠,
	٦١,٦٢,٦٣,٦٤,٦٥,٦٦,٦٧,٦٨,٦٩,٧٠,
	٧١,٧٢,٧٣,٧٤,٧٥,٧٦,٧٧,٧٨,٧٩,٨٠,
	٨١,٨٢,٨٣,٨٤,٨٥,٨٦,٨٧,٨٨,٨٩,٩٠,
	٩١,٩٢,٩٣,٩٤,٩٥,٩٦,٩٧,٩٨,٩٩,١٠٠,
	١٠١,١٠٢,١٠٣,١٠٤,١٠٥,١٠٦,١٠٧,١٠٨,١٠٩,١١٠,
	١١١,١١٢,١١٣,١١٤,١١٥,١١٦,١١٧,١١٨,١١٩,١٢٠,
	١٢١,١٢٢,١٢٣,١٢٤,١٢٥,١٢٦,١٢٧,١٢٨,١٢٩,١٣٠,
	١٣١,١٣٢,١٣٣,١٣٤,١٣٥,١٣٦,١٣٧,١٣٨,١٣٩,١١٣٠,
	١٤١,١٤٢,١٤٣,١٤٤,١٤٥,١٤٦,١٤٧,١٤٨,١٤٩,١٥٠,
	١٥١,١٥٢,١٥٣,١٥٤,١٥٥,١٥٦,١٥٧,١٥٨,١٥٩,١٦٠,
	١٦١,١٦٢,١٦٣,١٦٤,١٦٥,١٦٦,١٦٧,١٦٨,١٦٩,١٧٠,
	١٧١,١٧٢,١٧٣,١٧٤,١٧٥,١٧٦,١٧٧,١٧٨,١٧٩,١٨٠,
	١٨١,١٨٢,١٨٣,١٨٤,١٨٥,١٨٦,١٨٧,١٨٨,١٨٩,١٩٠,
	١٩١,١٩٢,١٩٣,١٩٤,١٩٥,١٩٦,١٩٧,١٩٨,١٩٩,٢٠٠,
	٢٠١,٢٠٢,٢٠٣,٢٠٤,٢٠٥,٢٠٦,٢٠٧,٢٠٨,٢٠٩,٢١٠,
	٢١١,٢١٢,٢١٣,٢١٤,٢١٥,٢١٦,٢١٧,٢١٨,٢١٩,٢٢٠,
	٢٢١,٢٢٢,٢٢٣,٢٢٤,٢٢٥,٢٢٦,٢٢٧,٢٢٨,٢٢٩,٢٣٠,
	٢٣١,٢٣٢,٢٣٣,٢٣٤,٢٣٥,٢٣٦,٢٣٧,٢٣٨,٢٣٩,٢٢٣٠,
	٢٤١,٢٤٢,٢٤٣,٢٤٤,٢٤٥,٢٤٦,٢٤٧,٢٤٨,٢٤٩,٢٥٠,
	٢٥١,٢٥٢,٢٥٣,٢٥٤,٢٥٥,٢٥٦,٢٥٧,٢٥٨,٢٥٩,٢٦٠,
	٢٦١,٢٦٢,٢٦٣,٢٦٤,٢٦٥,٢٦٦,٢٦٧,٢٦٨,٢٦٩,٢٧٠,
	٢٧١,٢٧٢,٢٧٣,٢٧٤,٢٧٥,٢٧٦,٢٧٧,٢٧٨,٢٧٩,٢٨٠,
	٢٨١,٢٨٢,٢٨٣,٢٨٤,٢٨٥,٢٨٦,٢٨٧,٢٨٨,٢٨٩,٢٩٠,
	٢٩١,٢٩٢,٢٩٣,٢٩٤,٢٩٥,٢٩٦,٢٩٧,٢٩٨,٢٩٩,٣٠٠,
]

%%% DOCUMENT

\starttext \showframe 

\section{section one}

\startlinenumbering
\input tufte
\input tufte
\stoplinenumbering

\dorecurse{20}{
\section{محمد الجمل (١٨٧٢—١٩٢٣)}
	مرحباً باعالم . ١٢٣٤٥٦٧٨٩٠ مرحباً بالعالم. ولد عام١٩٣٤.
\footnote{تعليقة لطيفة.}
\pagebreak
}

\stoptext
=============



> On 2 Aug 2015, at 18:15, Idris Samawi Hamid ادريس سماوي حامد <Idris.Hamid at colostate.edu> wrote:
> 
> Dear Talal,
> Salaam. See below:
> 
> On Sun, 02 Aug 2015 07:31:37 -0600, talazem at fastmail.fm <talazem at fastmail.fm> wrote:
> 
>> Thank you very much for this, Idris. It works nicely in the sample file you sent. But it goes off again once you add \setupdirections[bidi=global]. Consider the following:
>> 
>> ==========
> <snip>
> 
>> \setupdirections[bidi=global]
>> 
>> \setupthinrules[color=white]
>> \setupwhitespace[big]
>> 
>> \section{Incorrect}
>> \startlinenumbering
>> \startalignment[r2l]
>> هذه رسالة لطيفة ألفها العالم الكبير الفهامة النحرير.
>> هذه رسالة جامعة مانعة ألفها الشيخ الفاضل...
>> \thinrule
>> ===========
> 
> You're right. \thinrule has LR unicode characters which is probably why it gets thrown off. So if you turn off global bidi and then either 1) just go with either global RL or 2) invoke RL inside the linenumbering it will work:
> 
> % \setupdirections[bidi=global]
> \righttoleft %% global RL
> 
> or just
> 
> \startlinenumbering
> \righttoleft %% local RL, not needed if global RL invoked
> \startalignment[r2l]
> 
> Again, it's a barbarous (and temporary) workaround. See attached.
> 
> Wassalaam
> Idris
> 
> PS Unless there is a lot of Latin in the critical edition file, I would probably depend more on explicit dir commands (\righttolet, \lefttoright) and less on bidi, which is still buggy in a number of ways. Beyond the ConTeXt implementation: The unicode bidi algorithm was not designed with advanced typesetting and typography in mind, works best for text-editing etc. per se. so local bidi *may perhaps* be more useful than global bidi for the critical-edition portion your project.
> 
> I'm not at all suggesting that this particular bug should not be a priority; printing paragraph lines in a linenumbering environment *must* be direction-agnostic. Just a matter of general strategy to consider.
> -- 
> Idris Samawi Hamid
> Professor of Philosophy
> Colorado State University
> Fort Collins, CO 80523<r2l-linenumbering-arabic.tex><r2l-linenumbering-arabic.pdf>___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20150803/04286730/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: num-ar.pdf
Type: application/pdf
Size: 29884 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20150803/04286730/attachment-0001.pdf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20150803/04286730/attachment-0003.html>


More information about the ntg-context mailing list