3

I am new to ConTeXt world, however what I need to achieve is simply to be able to typeset Arabic/Hebrew text along with English text (Bidi) in ConTeXt. I came across this part of the context garden being relevant to what I am after, but to no avail at compilation, no PDF was generated and no errors were thrown.

These steps were followed as described in the link above:

  1. create ara-sty.tex file (code provided in the same link above), presumably in the same dir of the .tex file
  2. create the MWE.tex file below:

MWE: (compile with luatex)

\environment ara-sty
    \starttext
    \setarabic

    هذا نص بالعربية يحتوي على ارقام ١، ٢، ٣ بالعربية أيضاً.

    \stoptext


%%% Local Variables:
%%% mode: context
%%% TeX-master: t
%%% TeX-engine: luatex
%%% End:

Output file

Running `ConTeXt' on `MWE' with ``texexec --once --texutil  --engine=luatex --interface=en --passon="--synctex=1" --nonstop MWE.tex''

There is no PDF file generated, what am I missing here?

Notes

  1. compiling English-only files we successful using ConTeXt, the problem arises only dealing with Arabic/Hebrew text.
  2. ConTeXt version on mu Ubuntu machine context --version in the terminal: current version: 2015.05.18 12:26
  3. Luatex version luatex --version in terminal issues: This is LuaTeX, Version beta-0.80.0 (TeX Live 2015/Debian) (rev 5238)

Update-1

Now I updated ConteXt on my machine successfully as described in this link of ConTeXtgarden wiki for Ubuntu using the standalone installation and then initialized the tree in ./baschrc, and now I have these versions installed:

  1. ConTeXt

    mtx-context     | ConTeXt Process Management 1.01
    mtx-context     |
    mtx-context     | main context file: /usr/local/context/tex/texmf-context/tex/context/base/mkiv/context.mkiv
    mtx-context     | current version: 2017.06.27 18:05
    
  2. Luatex This is LuaTeX, Version 1.05.0 (TeX Live 2017)

  3. I get the same problem even with the latest stable release of ConTeXt: current version: 2017.05.15 21:48

So the same problem, no PDF file is generated, any help would be appreciated.

Update-2 After googling around, I found out that one issue is my Emacs setup (GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2017-05-06) using AucTeX needs some adjustment which is to set the ConTeXt-Mark-version variable to "IV" instead of its default "II".

After setting this globally in my dot file (setup Emacs file) as follows:

(setq ConTeXt-Mark-version "IV")  

Now, when I do compilation of the MWE I got these lines of complaint: Problems after (1) page.

Running `ConTeXt' on `MWE' with ``context --once --texutil  --synctex=1 --nonstop MWE.tex''

mtx-context     | warning: synctex is enabled
mtx-context     | run 1: luatex --fmt="/var/lib/texmf/luatex-cache/context/b47c3d3cee7cb6c86268d0595268c442/formats/luatex/cont-en" --interaction="nonstopmode" --jobname="MWE" --lua="/var/lib/texmf/luatex-cache/context/b47c3d3cee7cb6c86268d0595268c442/formats/luatex/cont-en.lui" --no-parse-first-line --synctex=1 --c:currentrun=1 --c:directives="system.synctex=1" --c:fulljobname="./MWE.tex" --c:input="./MWE.tex" --c:kindofrun=3 --c:maxnofruns=1 --c:nonstopmode --c:once --c:synctex="1" --c:texutil "cont-yes.mkiv"
This is LuaTeX, Version beta-0.80.0 (TeX Live 2015/Debian) (rev 5238) 
 \write18 enabled.

system          > synctex functionality is enabled (1)!
open source     > 1 > 1 > /usr/share/texmf/tex/context/base/cont-yes.mkiv

ConTeXt  ver: 2015.05.18 12:26 MKIV current  fmt: 2016.5.14  int: english/english

system          > 'cont-new.mkiv' loaded
open source     > 2 > 2 > /usr/share/texmf/tex/context/base/cont-new.mkiv
close source    > 2 > 2 > /usr/share/texmf/tex/context/base/cont-new.mkiv

system          > files > jobname 'MWE', input './MWE', result 'MWE'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
open source     > 2 > 3 > /home/ffs/.emacs.d/docs/context/MWE.tex
open source     > 3 > 4 > ara-sty.tex

tex error       > error on line 64 in file ara-sty.tex: ! Undefined control sequence

l.64 \setcharactermirroring
                         [1]

54        \usetypescript[lm]%
55        \setupbodyfont[lm,20pt]}
56     
57     \definestartstop
58       [latinpar]
59       [commands=\Arabic\LatinParDir]
60     
61     \define[1]\LT
62       {{\LatinTextDir#1}}
63     
64 >>  \setcharactermirroring[1]
65     
66     \stopenvironment
67     
68     
69     
70     %%% Local Variables:
71     %%% mode: context
72     %%% TeX-master: t
73     %%% End:
74     


close source    > 3 > 4 > ara-sty.tex
fonts           > preloading latin modern fonts (second stage)
fonts           > 'fallback modern-designsize rm 12pt' is loaded
fonts           > bodyfont '20pt' is defined (can better be done global)
fonts           > bodyfont '24pt' is defined (can better be done global)
fonts           > bodyfont '16pt' is defined (can better be done global)
backend         > xmp > using file '/usr/share/texmf/tex/context/base/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1
close source    > 2 > 4 > /home/ffs/.emacs.d/docs/context/MWE.tex
close source    > 1 > 4 > /usr/share/texmf/tex/context/base/cont-yes.mkiv

mkiv lua stats  > used config file: /usr/share/texmf/web2c/texmfcnf.lua;/usr/share/texlive/texmf-dist/web2c/texmfcnf.lua
mkiv lua stats  > used cache path: readable: '/var/lib/texmf/luatex-cache/context/b47c3d3cee7cb6c86268d0595268c442' | readable+writable: '/home/ffs/.texmf-var/luatex-cache/context/b47c3d3cee7cb6c86268d0595268c442'
mkiv lua stats  > synctex tracing: synctex has been enabled (extra log file generated)
mkiv lua stats  > resource resolver: loadtime 0.129 seconds, 0 scans with scantime 0.000 seconds, 0 shared scans, 10 found files, scanned paths: <none>
mkiv lua stats  > stored bytecode data: 371 modules (0.335 sec), 78 tables (0.009 sec), 449 chunks (0.344 sec)
mkiv lua stats  > traced context: maxstack: 1134, freed: 2, unreachable: 1132
mkiv lua stats  > running in nuts mode: yes
mkiv lua stats  > cleaned up reserved nodes: 44 nodes, 439 lists of 438
mkiv lua stats  > node memory usage: 2 glue, 2 penalty, 9 attribute, 35 glue_spec, 3 attribute_list, 2 temp
mkiv lua stats  > node list callback tasks: 6 unique task lists, 5 instances (re)created, 44 calls
mkiv lua stats  > used backend: pdf (backend for directly generating pdf output)mkiv lua stats  > loaded patterns: ar::26 en::2, load time: 0.000
mkiv lua stats  > jobdata time: 0.000 seconds saving, 0.000 seconds loading
mkiv lua stats  > callbacks: 176 direct, 312 indirect, 488 total
mkiv lua stats  > result saved in file: MWE.pdf, compresslevel 3, objectcompresslevel 3
mkiv lua stats  > loaded fonts: 2 files: latinmodern-math.otf, lmroman12-regular.otf
mkiv lua stats  > fonts load time: 0.263 seconds for 7 fonts, 2 shared in backend, 0 common vectors, 2 common hashes
mkiv lua stats  > used platform: linux-64, type: unix, binary subtree: usr
mkiv lua stats  > luatex banner: this is luatex, version beta-0.80.0 (tex live 2015/debian) (rev 5238)
mkiv lua stats  > control sequences: 44153 of 65536 + 100000
mkiv lua stats  > lua properties: engine: lua, used memory: 90 MB (ctx: 90 MB), hash type: lua, hash chars: min(64,40), symbol mask: utf (τεχ)
mkiv lua stats  > runtime: 0.680 seconds, 1 processed pages, 1 shipped pages, 1.471 pages/second

SyncTeX written on MWE.synctex.gz.
mtx-context     | fatal error: return code: 1
TeX Output exited abnormally with code 1 at Thu Jun 29 03:50:01

I noticed from the error message above that my luatex is 2015 instead of being updated to 2017 as shown earlier in this post, so how can I fix that?

4
  • I get an error when I try to compile your document. Undefined control sequence \setarabic.
    – TH.
    Commented Jun 28, 2017 at 19:06
  • @TH. You have to create ara-sty.tex first. The file's contents can be found in the Garden: wiki.contextgarden.net/Arabic_and_Hebrew Commented Jun 28, 2017 at 21:33
  • @HenriMenke Thanks, I read the question too quickly and missed that.
    – TH.
    Commented Jun 28, 2017 at 21:44
  • Seems like \setcharactermirroring is not available in MKIV. Commented Jun 29, 2017 at 3:00

1 Answer 1

5

[Disclaimer: Neither do I speak arabic nor do I have any understanding of the arabic script.]

I copied the relevant stuff to setup the arabic font from ara-sty.tex. That is the font features and setting right-to-left mode. Then I wrote a typescript for the arabic Amiri font with a fallback to Latin Modern for latin characters. It works with ConTeXt MKIV on TL2017, but I don't know if this is what you are looking for.

\definefontfeature
  [arabic]
  [mode=node,language=dflt,script=arab,
   init=yes,medi=yes,fina=yes,isol=yes,
   liga=yes,dlig=yes,rlig=yes,clig=yes,
   mark=yes,mkmk=yes,kern=yes,curs=yes]

\definefontfallback
  [latin-fallback]
  [file:lmroman12-regular*default]
  [basiclatin,
   latin-1supplement,
   latinextended-A,
   latinextendedadditional]
  [force=yes]

\starttypescriptcollection [amiri]

  \starttypescript [serif] [amiri]
    \definefontsynonym [Serif]           [file:amiri-regular.ttf]     [features=arabic]
    \definefontsynonym [SerifItalic]     [file:amiri-slanted.ttf]     [features=arabic]
    \definefontsynonym [SerifBold]       [file:amiri-bold.ttf]        [features=arabic]
    \definefontsynonym [SerifBoldItalic] [file:amiri-boldslanted.ttf] [features=arabic]
  \stoptypescript

  \starttypescript [amiri]
    \definetypeface [\typescriptone] [rm] [serif] [amiri]  [default] [fallbacks=latin-fallback]
    \definetypeface [\typescriptone] [ss] [sans]  [modern] [default] 
    \definetypeface [\typescriptone] [tt] [mono]  [modern] [default] 
    \definetypeface [\typescriptone] [mm] [math]  [modern] [default] 
  \stoptypescript 

\stoptypescriptcollection

\starttypescriptcollection [sblhbrw]

  \starttypescript [serif] [sblhbrw]
    \definefontsynonym [Serif] [file:SBL_Hbrw.ttf] [features=arabic]
  \stoptypescript

  \starttypescript [sblhbrw]
    \definetypeface [\typescriptone] [rm] [serif] [sblhbrw] [default] [fallbacks=latin-fallback]
    \definetypeface [\typescriptone] [ss] [sans]  [modern]  [default] 
    \definetypeface [\typescriptone] [tt] [mono]  [modern]  [default] 
    \definetypeface [\typescriptone] [mm] [math]  [modern]  [default] 
  \stoptypescript 

\stoptypescriptcollection

\setupbodyfont[amiri]
\setupbodyfont[sblhbrw]
\setupbodyfont[modern]

\define\setarabic{%
  \pagedir TRT \bodydir TRT \pardir  TRT \textdir TRT
  \switchtobodyfont[amiri]
}

\define\sethebrew{%
  \pagedir TRT \bodydir TRT \pardir  TRT \textdir TRT
  \switchtobodyfont[sblhbrw]
}

\define\setlatin{%
  \pagedir TLT \bodydir TLT \pardir  TLT \textdir TLT
  \switchtobodyfont[modern]
}

\starttext

\setarabic
هذا نص بالعربية يحتوي على ارقام ١، ٢، ٣ بالعربية أيضاً.

{\it هذا نص بالعربية يحتوي على ارقام ١، ٢، ٣ بالعربية أيضاً.}

{\bf هذا نص بالعربية يحتوي على ارقام ١، ٢، ٣ بالعربية أيضاً.}

{\bi هذا نص بالعربية يحتوي على ارقام ١، ٢، ٣ بالعربية أيضاً.}

\setlatin
\input lorem

\sethebrew
אברית

\stoptext

enter image description here

7
  • Great! thanks a lot. It works now, could you please extend your example to put English (left-to-right) as well as Hebrew (e.g. אברית) text (right-to-left) in flow text along with the Arabic text? The idea is to write bidirectional text. I deeply appreciate your help.
    – doctorate
    Commented Jun 29, 2017 at 7:07
  • I compiled the above MWE successfully with PDF output, but the log file shows the following: mkiv lua stats > luatex banner: this is luatex, version beta-0.80.0 (tex live 2015/debian) (rev 5238) mkiv lua stats > control sequences: 43238 of 65536 + 100000 mkiv lua stats > lua properties: engine: lua, used memory: 125 MB (ctx: 125 MB), hash type: lua, hash chars: min(64,40), symbol mask: utf (τεχ) mkiv lua stats > runtime: 1.072 seconds, 1 processed pages, 1 shipped pages, 0.933 pages/second My concern is that compilation shows luatex version 2015 while I installed the 2017 version?
    – doctorate
    Commented Jun 29, 2017 at 7:11
  • @doctorate See updated answer. I downloaded the SBL Hebrew from here and placed it in the working directory. Commented Jun 29, 2017 at 10:27
  • @HenriMenke You can remove the \pagedir and \bodydir settings because ConTeXt disables both commands. To change the direction of texts and paragraphs use \setupalign[r2l] or \righttoleft instead of \textdir and \pardir because ConTeXt’s alignment commands set flags which are used for other mechanism (e.g. itemize). Commented Jun 29, 2017 at 17:15
  • @Metafox, you are right about those replacements you mentioned above, and they gave the same results, except for one difference at least to my eyes and with a different flow bidi text than what in the MWE above, that there was a difference in the glue spaces between the glyphs, i.e. with the former code text looks more compact (less glue) than with the latter code you suggested.
    – doctorate
    Commented Jun 30, 2017 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .