[XeTeX] Using hebrew

Yaniv Hollander yaniv.hollander at gmail.com
Wed Mar 7 07:12:36 CET 2007


Hi,

Can you send me an example that works. I tried using this package,  
but hebrew fonts couldn't be displayed.

Thanks,

On Mar 6, 2007, at 9:53 PM, François Charette wrote:

>
> Dear Yaniv,
>> On 6 Mar 2007, at 1:52 pm, Yaniv Hollander wrote:
>>
>>> Does anyone knows what is the best method to create Hebrew   
>>> documents with Latex/XeLatex?
>>>
>> Handling right-to-left layout properly for all the various LaTeX   
>> environments, document classes, etc., will require some  
>> additional  work; the simple
>> \everypar setting here is just for normal paragraphs of text.  
>> Perhaps  some of the experienced R-L script users on the list can  
>> offer more  extensive examples of working with Hebrew, Arabic, and  
>> similar scripts.
>>
>> JK
>>
> You may try out my LaTeX package bidi.sty (attached), which mostly  
> borrows code from rlbabel.def and adds a fews bells and whistles.  
> It is part of my arabxetex package, which I intend to upload to  
> CTAN very soon (I should have done it two months ago but work  
> overload prevented it ;-)
>
> bidi takes a generic approach to bidirectional typesetting and is  
> targeted at XeLaTeX users.
>
> It defines the following macros:
> * \LR{...} and \RL{...} (for short insertions)
> * \setRL and \setLR (= \unsetRL) to switch paragraph direction  
> globally.
> * \setfootnoteRL and \setfootnoteLR  (= \unsetfootnoteRL) to have  
> direction of plain footnotes other than the main paragraph direction.
>
> There are also macros for writing alphabetic numerals in Arabic  
> (Eastern and Western abjad) and Hebrew (rather primitive  
> implementation for now):
> * \abjad{...}
> * \abjadmaghribi{...}
> * and \hebrewnumeral{...}.
>
> NB: I'll post a notice when arabxetex is on CTAN. It shouldn't take  
> too long :-)
>
> And, as I think about it, I shall actually upload bidi as a  
> separate package instead of leaving it as an ancillary to arabxetex.
>
> Best wishes,
>
> François
>
> %%
> %%   The bidi package for (X)eLaTeX
> %%   (C) 2006-2007  François Charette <firmicus at gmx.net>
> %%
> %%
> %% Distributable under the LaTeX Project Public License,
> %% version 1.3c or higher (your choice). The latest version of
> %% this license is at: http://www.latex-project.org/lppl.txt
> %%
> %% This is a pre-release version!
> %% Check CTAN for the official release
> %%
> \NeedsTeXFormat{LaTeX2e}
> \ProvidesPackage{bidi}
>   [2007/03/06 v0.2a  Bidirectional typesetting in (X)eLaTeX]
> \newif\if at rlmain
> \@rlmainfalse
> \DeclareOption{rldocument}{\@rlmaintrue}
> \ExecuteOptions{rldocument}
> \ProcessOptions
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %% most of the following is taken from rlbabel.def
> \ifx\TeXXeTstate\undefined\else%
>    \TeXXeTstate=1
> \fi
> \ifx\beginL\@undefined%
>    \newlinechar`\^^J
>    \typeout{^^JTo avoid this error message,^^J%
>      run TeX--XeT or e-TeX engine instead of regular TeX.^^J}
>    \errmessage{Right-to-Left Support Error: use TeX--XeT or e-TeX
>      engine}%
> \fi
> \newif\if at rl
> \AtBeginDocument{% Here we set the main document direction
>   \if at rl\@rlmaintrue%
>   \else\@rlmainfalse%
>   \fi%
> }
> \let\n at xt=\
> \def\LR{\protect\pLR}%
> \def\pLR{\protect\afterassignment\moreLR \let\n at xt= }
> \def\moreLR{\bracetext \aftergroup\endL \beginL\@rlfalse}
> \def\RL{\protect\pRL}
> \def\pRL{\protect\afterassignment\moreRL \let\n at xt= }
> \def\moreRL{\bracetext \aftergroup\endR \beginR\@rltrue}
> \def\bracetext{\ifcat\n at xt{\else\ifcat\n at xt}\fi
>   \errmessage{Missing left brace has been substituted}\fi \bgroup}
> \everydisplay{\if at rl\aftergroup\beginR\fi }
> \def\rl at everypar{\if at rl{\setbox\z@\lastbox\beginR\usebox\z@}\fi}
> \let\o at everypar=\everypar
> %% The following, surely, will not play well with all packages,  
> e.g. ledmac
> %\def\everypar#1{\o at everypar{\rl at everypar#1}}
> %%% But we now try this instead, taken from Arabicore.sty in the  
> Arabi package
> % Thanks to Youssef Jabri! Shukran jazilan!
> \newtoks\n at everypar
> \n at everypar\expandafter{\the\o at everypar}
> \o at everypar{\rl at everypar\the\n at everypar}
> \let\everypar=\n at everypar
>
> % Make this a separate package?  Move to arabxetex??
> % ABJAD -- again mostly borrowed from Arabi package
> % NB: This could be abstracted to support Greek, Hebrew, Arabic  
> (Eastern and Western), etc
>
> \def\abjad#1{%
> \ifnum#1>1999 \PackageWarning{bidi}{Illegal value (#1) for abjad  
> numeral} {#1}
> \else
>   \ifnum#1<\z@\space\PackageWarning{bidi}{Illegal value (#1) for  
> abjad numeral}%
>   \else
>     \ifnum#1<10\expandafter\abj at num@i\number#1%
>     \else
>       \ifnum#1<100\expandafter\abj at num@ii\number#1%
>       \else
>         \ifnum#1<\@m\expandafter\abj at num@iii\number#1%
>         \else
>           \ifnum#1<\@M\expandafter\abj at num@iv\number#1%since  
> #1<2000, we must have 1000
>           \fi
>         \fi
>       \fi
>     \fi
>   \fi
> \fi
> }
>
> \def\abjadmaghribi#1{%
> \ifnum#1>1999 \PackageWarning{bidi}{Illegal value (#1) for abjad  
> numeral} {#1}
> \else
>   \ifnum#1<\z@\space\PackageWarning{bidi}{Illegal value (#1) for  
> abjad numeral}%
>   \else
>     \ifnum#1<10\expandafter\abj at num@i\number#1%
>     \else
>       \ifnum#1<100\expandafter\abj at maghribi@num at ii\number#1%
>       \else
>         \ifnum#1<\@m\expandafter\abj at maghribi@num at iii\number#1%
>         \else
>           \ifnum#1<\@M\expandafter\abj at maghribi@num at iv\number#1% 
> since #1<2000, we must have 1000
>           \fi
>         \fi
>       \fi
>     \fi
>   \fi
> \fi
> }
>
> \def\hebrewnumeral#1{%
> \ifnum#1>9999 \PackageWarning{bidi}{Illegal value (#1) for Hebrew  
> numeral} {#1}
> \else
>   \ifnum#1<\z@\space\PackageWarning{bidi}{Illegal value (#1) for  
> Hebrew numeral}%
>   \else
>     \ifnum#1<10\expandafter\heb at num@i\number#1%
>     \else
>       \ifnum#1<100\expandafter\heb at num@ii\number#1%
>       \else
>         \ifnum#1<\@m\expandafter\heb at num@iii\number#1%
>         \else
>           \ifnum#1<\@M\expandafter\heb at num@iv\number#1%
>           \fi
>         \fi
>       \fi
>     \fi
>   \fi
> \fi
> }
> % default abjad zero is not defined, but if a package writer or  
> user has a font
> % with the appropriate glyph (e.g. as found in medieval  
> manuscripts), then it can be
> % redefined
> \def\abjad at zero{}
> \def\hebnum at zero{}
>
> \def\abj at num@i#1{%
>   \ifcase#1\or ا\or ب\or ج\char"200D\or د\or ه\or و\or ز\or ح 
> \or ط\fi
>   \ifnum#1=\z@\abjad at zero\fi}
> \def\abj at num@ii#1{%
>   \ifcase#1\or ي\or ك\or ل\or م\or ن\or س\or ع\or ف\or ص\fi
>   \ifnum#1=\z@\fi\abj at num@i}
> \def\abj at num@iii#1{%
>   \ifcase#1\or ق\or ر\or ش\or ت\or ث\or خ\or ذ\or ض\or ظ\fi
>   \ifnum#1=\z@\fi\abj at num@ii}
> \def\abj at num@iv#1{%
>   \ifcase#1\or غ\fi
>   \ifnum#1=\z@\fi\abj at num@iii}
>
> %maghribi س -> ص ص->ض ش->س ض->ظ ظ->غ غ->ش
> \def\abj at maghribi@num at ii#1{%
>   \ifcase#1\or ي\or ك\or ل\or م\or ن\or ص\or ع\or ف\or ض\fi
>   \ifnum#1=\z@\abjad at zero\fi\abj at num@i}
> \def\abj at maghribi@num at iii#1{%
>   \ifcase#1\or ق\or ر\or س\or ت\or ث\or خ\or ذ\or ظ\or غ\fi
>   \ifnum#1=\z@\fi\abj at maghribi@num at ii}
> \def\abj at maghribi@num at iv#1{%
>   \ifcase#1\or ش\fi
>   \ifnum#1=\z@\fi\abj at maghribi@num at iii}
>
> %Hebrew alphabetic numerals (primitive implementation -- the code  
> in Babel is more complex):
> \def\heb at num@i#1{%
>   \ifcase#1\or א\or ב\or ג\or ד\or ה\or ו\or ז\or ח\or ט\fi
>   \ifnum#1=\z@\hebnum at zero\fi}
> \def\heb at num@ii#1{%
>   \ifcase#1\or י\or כ\or ל\or מ\or נ\or ס\or ע\or פ\or צ\fi
>   \ifnum#1=\z@\fi\heb at num@i}
> \def\heb at num@iii#1{%
>   \ifcase#1\or ק\or ר\or ש\or ת\or ך\or ם\or ן\or ף\or ץ\fi
>   \ifnum#1=\z@\fi\heb at num@ii}
> \def\heb at num@iv#1{%
>   \ifcase#1\or א׳\or ב׳\or ג׳\or ד׳\or ה׳\or ו׳\or ז׳ 
> \or ח׳\or ט׳\fi
>   \ifnum#1=\z@\fi\heb at num@iii}
> %TODO [optionally] insert gereshayim ״ before last letter of a  
> sequence of two letters or more
> %                  insert geresh ׳ after letter if it is alone
>
> %Farsi (not a "real" abjad system) :
> \def\farsialphanum#1{%
> \ifnum#1>32 \PackageWarning{bidi}{Illegal value (#1) for Farsi  
> alphabetic numeral} {#1}
> \else\farsi at abjad{#1}\fi}
>
> \def\farsi at abjad#1{\ifcase#1\or ا\or ب\or پ\or ت\or ث\or ج\or چ
> \or ح\or خ\or د\or ذ\or ر\or ز\or ژ\or س\or ش\or ص\or ض 
> \or ط\or ظ
> \or ع\or غ\or ف\or ق\or ك\or گ\or ل\or م\or ن\or و\or ه 
> \or ي\fi}
>
> %----------------------------------------
>
> \def\@ensure at RL#1{\if at rl#1\else\RL{#1}\fi}
> \def\@ensure at LR#1{\if at rl\LR{#1}\else#1\fi}
>
> %%%preserve logos
> \let\@@TeX\TeX
> \def\TeX{\LR{\@@TeX}}
> \let\@@LaTeX\LaTeX
> \def\LaTeX{\LR{\@@LaTeX}}
> \let\@@LaTeXe\LaTeXe
> \def\LaTeXe{\LR{\@@LaTeXe}}
> \@ifpackageloaded{xltxtra}{
> \let\@@XeTeX\XeTeX
> \def\XeTeX{\LR{\@@XeTeX}}
> }{}
> %%%VARIOUS LATEX MACROS
> \def\list#1#2{%
>   \ifnum \@listdepth >5\relax
>     \@toodeep
>   \else
>     \global\advance\@listdepth\@ne
>   \fi
>   \rightmargin\z@
>   \listparindent\z@
>   \itemindent\z@
>   \csname @list\romannumeral\the\@listdepth\endcsname
>   \def\@itemlabel{#1}%
>   \let\makelabel\@mklab
>   \@nmbrlistfalse
>   #2\relax
>   \@trivlist
>   \parskip\parsep
>   \parindent\listparindent
>   \advance\linewidth -\rightmargin
>   \advance\linewidth -\leftmargin
>   \if at rl
>     \advance\@totalleftmargin \rightmargin
>   \else
>     \advance\@totalleftmargin \leftmargin
>   \fi
>   \parshape \@ne \@totalleftmargin \linewidth
>   \ignorespaces}
> %%%
> \def\@dottedtocline#1#2#3#4#5{%
>   \ifnum #1>\c at tocdepth \else
>     \vskip \z@ \@plus.2\p@
>     {\if at rl\rightskip\else\leftskip\fi #2\relax
>       \if at rl\leftskip\else\rightskip\fi \@tocrmarg \parfillskip
>       -\if at rl\leftskip\else\rightskip\fi
>      \parindent #2\relax\@afterindenttrue
>      \interlinepenalty\@M
>      \leavevmode
>      \@tempdima #3\relax
>      \advance\if at rl\rightskip\else\leftskip\fi \@tempdima
>      \null\nobreak\hskip -\if at rl\rightskip\else\leftskip\fi
>      {#4}\nobreak
>      \leaders\hbox{$\m at th
>         \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
>         mu$}\hfill
>      \nobreak
>      \hb at xt@\@pnumwidth{\hfil\normalfont \normalcolor \beginL#5\endL}%
>      \par}%
>   \fi}
> %%% implement bidirectionality of Latex footnotes
> \newif\if at rl@footnote
> \if at rl\@rl at footnotetrue\else\@rl at footnotefalse\fi
> \let\@@footnoterule=\footnoterule
> \def\LRfootnoterule{\@@footnoterule}
> \def\RLfootnoterule{\vskip -\baselineskip\hb at xt@\hsize{\hss\vbox 
> {\@@footnoterule}}} %BUG?-->this causes new par to be set, hence  
> hack with vskip :-{
> \def\setfootnoteRL{\@rl at footnotetrue}
> \def\unsetfootnoteRL{\@rl at footnotefalse}
> \def\setfootnoteLR{\unsetfootnoteRL}
> %
> \def\footnoterule{\if at rl@footnote\RLfootnoterule\else\LRfootnoterule 
> \fi}
> %%% DIR SWITCHING COMMANDS
> \def\setRL{\@rltrue\@rl at footnotetrue}
> \def\unsetRL{\@rlfalse\@rl at footnotefalse}
> \def\setLR{\unsetRL}
> %
> %
> \long\def\@footnotetext#1{\insert\footins{%
>     \if at rl@footnote\@rltrue\else\@rlfalse\fi
>     \reset at font\footnotesize
>     \interlinepenalty\interfootnotelinepenalty
>     \splittopskip\footnotesep
>     \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
>     \hsize\columnwidth \@parboxrestore
>     \protected at edef\@currentlabel{%
>        \csname p at footnote\endcsname\@thefnmark
>     }%
>     \color at begingroup
>       \@makefntext{%
>         \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
>     \color at endgroup}}%
> %... also in minipages
> \long\def\@mpfootnotetext#1{%
>   \global\setbox\@mpfootins\vbox{%
>     \if at rl@footnote\@rltrue\else\@rlfalse\fi
>     \unvbox\@mpfootins
>     \reset at font\footnotesize
>     \hsize\columnwidth
>     \@parboxrestore
>     \protected at edef\@currentlabel
>          {\csname p at mpfootnote\endcsname\@thefnmark}%
>     \color at begingroup
>       \@makefntext{%
>         \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
>     \color at endgroup
>     }}
> %%%
> \ifx\@textcolor\@undefined\else%
> \AtBeginDocument{%
>   %I assume that \@textcolor is only defined by the package color
>     % If that macro was defined before the beginning of the document,
>     % that is: the package was loaded: redefine it with bidi support
>     \def\@textcolor#1#2#3{%
>       \if at rl%
>       %%% >>> NB: THIS DOES NOT WORK when the text spans more than  
> one line!!!
>       %%%         -> we need bidi aware PS/PDF engines (xdvipdfmx??)
>       \beginL\protect\leavevmode{\color#1{#2}\beginR#3\endR}\endL%
>       \else%
>         \protect\leavevmode{\color#1{#2}#3}%
>       \fi%
>     }%
> }%
> \fi
> %%%
> \def\raggedright{%
>   \let\\\@centercr
>   \leftskip\z at skip\rightskip\@flushglue
>   \parindent\z@\parfillskip\z at skip}
> \let\@@raggedleft=\raggedleft
> \let\@@raggedright=\raggedright
> \renewcommand\raggedleft{\if at rl\@@raggedright%
>                          \else\@@raggedleft\fi}
> \renewcommand\raggedright{\if at rl\@@raggedleft%
>                           \else\@@raggedright\fi}
> %% IMPLEMENT THE NEXT TWO LINES AT THE CLASS LEVEL
> %\let\@@author=\author
> %\renewcommand{\author}[1]{\@@author{\if at rl\beginR #1\endR\else #1 
> \fi}}
> %% These are useless here ...
> %\let\@@MakeUppercase=\MakeUppercase
> %\def\MakeUppercase#1{\if at rl#1\else\@@MakeUppercase{#1}\fi}
> %\let\@@MakeLowercase=\MakeLowercase
> %\def\MakeLowercase#1{\if at rl#1\else\@@MakeLowercase{#1}\fi}
> \let\@@@underline=\underline
> \def\underline#1{\@@@underline{\if at rl\RL{#1}\else #1\fi}}
> \if at compatibility
>    \let\undertext=\underline
> \fi
>
>
> \endinput
>
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex

Yaniv                       Hollander
yaniv.hollander at gmail.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/xetex/attachments/20070307/36c40ea6/attachment-0001.html 


More information about the XeTeX mailing list