%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % arabtex.sty % this is the driver module for the ArabTeX macro package % 13.07.94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (c) Klaus Lagally % Institut fuer Informatik % Universitaet Stuttgart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifx \arabatcode \undefined \else \expandafter \endinput \fi % load only once \chardef \arabatcode = \catcode`\@ \catcode`\@ = 11 \chardef \@other = 12 \newtoks \version \newtoks \datum %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \ArabTeX {Arab\TeX } \version = {3.02} \datum = {13.07.94} \message {\the\version } \message {(\the\datum )} \edef \arabtexconfig {arabtex.sty \the\version \space (\the\datum) } %%%%%%%%%%%%%%%%%%% various declarations %%%%%%%%%%%%%%%%%%%%% \let \xpa \expandafter \let \nxp \noexpand \def \n@xp {\nxp \nxp \nxp } \newbox \wordb@x \newbox \lineb@x \newbox \tempb@x \newtoks \a@tokens \newtoks \sc@next \newtoks \sc@rest \newtoks \a@@cmd \newtoks \a@@name \newtoks \a@@tail \newtoks \a@digits \newtoks \a@first \newtoks \a@paren \newtoks \a@@everypar \newtoks \a@last \newskip \a@parindent \newskip \a@parskip \newwrite \a@@err \newwrite \a@@out \newcount \tracingarab \def \quiet {\tracingarab = 0 } \newif \if@vocals \newif \ifv@c \newif \if@sukun \newif \if@suk \newif \if@wasla \newif \if@was \newif \if@high \newif \ifacc@hi \newif \ifa@vmode \newif \ifa@space \newif \iftr@ns \newif \ifa@oldhmode \newif \iftest % \testtrue % for internal use only \newif \iftest@scan \newif \iftest@trans \newif \iftest@parse \newif \iftest@write %%%%%%%%%%%%%%%%%%% language specific switches %%%%%%%%%%%%%%%%%%%%% \newif \ifarab % generate the arabic script \newif \ifshow % display the input text verbatim \newif \ifligs % set all ligatures active \newif \ifspread % spread characters by keshide \newif \iftrans % generate the transliteration \newif \ifaN@alif % tanwin on alif \newif \ifqur@n % old hamza rules \newif \ifh@mza % hamza rules, assimilation \newif \ifiz@fet % izafet rules \newif \ifyahd@ts % yah with dots \newif \ifk@fs % final kaf without mark \newif \ifpasht@ % loop chars, e as two dots, diphtongs \newif \ifurd@ % e as long yah, urdu accent, two hah chars \newif \ifmagh@ % variants of fah, vah and qaf \newif \ift@rk % special transliteration and coding \newif \ifk@rd % special transliteration and coding \newif \ifn@arab % load Arabic default %%%%%%%%%%%%%%%%%%% various options %%%%%%%%%%%%%%%%%%%%% \def \yahdots {\yahd@tstrue } \def \yahnodots {\yahd@tsfalse } \def \accentshigh {\acc@hitrue } \def \accentslow {\acc@hifalse } \def \oldtanwin {\aN@aliffalse } \def \newtanwin {\aN@aliftrue } \def \oldhamza {\qur@ntrue } \def \newhamza {\qur@nfalse } %%%%%%%%%%%%%%%%%%% various defaults %%%%%%%%%%%%%%%%%%%%% \def \transtrue {% activate the transliteration \iftr@ns \else \tr@zdmg \fi \let \iftrans \iftrue } \let \tr@zdmg \relax \n@arabtrue \def \arab@output {\ifn@arab % switch to Arabic output conventions \def@arabskel % define character skeletons for Arabic \def@arabchars % define character macros for Arabic \def@arabaccent % define accent macros for Arabic \def@arabvoc % define vowel parsing routines for Arabic \def@arabstrut % define strut for Arabic \tr@zdmg % define standard transliteration \let \a@write \a@@write \let \a@write@hook \relax \n@arabfalse \fi } %%%%%%%%%%%%%%%%%%% language selection %%%%%%%%%%%%%%%%%%%%% \def \all@false {% reset language code to default \k@rdfalse \t@rkfalse \magh@false \urd@false \pasht@false \arab@output \catcode`\<=\active } \def \setarab {% kaf with mark, hamza rules, yah with dots \all@false \iz@fetfalse \h@mzatrue \yahd@tstrue \k@fsfalse \oldtanwin \setnash } \def \setmaghribi {% variants of fah and qaf \setarab \magh@true } \def \setfarsi {% no kaf mark, yah without dots, izafet \all@false \iz@fettrue \h@mzatrue \yahd@tsfalse \k@fstrue \newtanwin \setnast } \def \setkurdish {% no kaf mark, yah without dots, izafet \setfarsi \k@rdtrue } \def \setturk {% kaf with mark, yah without dots, izafet, hamza \all@false \iz@fettrue \h@mzatrue \yahd@tsfalse \k@fsfalse \newtanwin \setnash \t@rktrue } \def \seturdu {% two hah, long yah, urdu accent, long e, izafet \all@false \iz@fettrue \h@mzatrue \yahd@tsfalse \k@fstrue \newtanwin \setnast \urd@true } \def \setpashto {% pashto loop, e: two dots, izafet, hamza \all@false \iz@fettrue \h@mzatrue \yahd@tstrue \k@fstrue \newtanwin \setnast \pasht@true } \def \setverb {% no special processing \all@false \iz@fetfalse \h@mzafalse \yahd@tstrue \k@fsfalse \oldtanwin \setnash } \def \setnone {% deselect arabic quotations \setverb \catcode`\<=\@other } \def \setquot {% select arabic quotations \catcode`\<=\active } %%%%%%%%%%%%%%%%%%%%%%% vowelization options %%%%%%%%%%%%%%%%%%%%%%%% \def \novocalize {% no diacritics except explicitly indicated \@vocalsfalse \v@cfalse \@sukunfalse \@sukfalse } \def \v@calize {% diacritics for short vowels only \@vocalstrue \v@ctrue \@sukunfalse \@sukfalse } \def \fullv@calize {% all diacritics \@vocalstrue \v@ctrue \@sukuntrue \@suktrue } \let \vocalize \v@calize \let \fullvocalize \fullv@calize %%%%%%%%%%%%%%%%%%%%%%%% list utilities %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newif \ifin@list \newif \ifend@char \def \test@in@list #1#2>{% #1 = token to check, #2 = list \begingroup \def \l@@kup ##1#1##2>{% look for the token \ifx \relax ##2\relax \global\in@listfalse \else \global\in@listtrue \fi }% \l@@kup #2#1>\endgroup } \def \test@in@set #1#2{% #1 = symbol, #2 = token list of symbols \xpa \test@in@list \xpa #1\the #2>} \a@last = {aAdFrzjwUO\a@r\a@d\a@D\a@z\a@R\a@H\a@W} \def \test@end@char #1{% does not connect to the left \ifx #1>\end@chartrue \else \test@in@set #1\a@last \ifin@list \end@chartrue \else \end@charfalse \fi\fi } %%%%%%%%%%%%%%%%%%%%%%%% font selection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifx \nashbf \undefined % nashbf.sty not yet loaded \gdef \nashbf {\global \let \nashbf \nash \setnash % default \message {nashbf.sty not loaded; bold-face ignored }\nash } \fi \ifx \nastaliq \undefined % nastaliq.sty not yet loaded \gdef \nastaliq {\global \let \nastaliq \nash \setnash % default \message {nastaliq.sty not loaded; nash is used instead }\nash } \fi \def \setarabfont #1{\def \set@arabfont {#1}} \def \setnash {\setarabfont \nash } \def \setnashbf {\setarabfont \nashbf } \def \setnastaliq {\setarabfont \nastaliq } \let \setnast \setnastaliq %%%%%%%%%%%%%%%%%%%%%%%% handling of special characters %%%%%%%%%%%%%%% \def \arab@codes {% save and set special characters \chardef \dqc@de = \catcode`\" \catcode`\" = \@other \chardef \lsc@de = \catcode`\< \catcode`\< = \@other } \def \unarab@codes {% reset catcodes \catcode`\< = \lsc@de \catcode`\" = \dqc@de } \let \@@ldtie ~ \def ~{\protect \@@ldtie} %%%%%%%%%%%%%%%%%%%%%%% Arabic environment %%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \arabtext {% environment for inverse formatting \arab@codes \set@arabfont \@waslafalse \@wasfalse \a@parindent \parindent \a@parskip \parskip \a@@everypar {}% \ifhmode \a@oldhmodetrue \a@vmodefalse \parindent \z@ \parskip \z@ plus 1\p@ \relax \initlineb@x \else \a@oldhmodefalse \a@vmodetrue \fi \def \\{\hfil \break } \let \| \break \let \emphasize \underbar % define internal commands \let \a@short@line \short@line \let \a@put@line \put@line \def \next@command {\test@special}% \a@spacetrue \spreadfalse \test@token } \def \a@par {% end an Arabic paragraph \ifa@vmode \else \last@line \spreadfalse \a@vmodetrue \parindent \a@parindent \parskip \a@parskip \vskip \parskip \ifnum \tracingarab > 0 \message {##}\fi \fi } \let \a@@par \a@par % save for \a@@everypar in \a@c@autopar \def \endarabtext {% end arabic environment \last@line \ifa@oldhmode \parskip \a@parskip \noindent \fi \ifnum \tracingarab > 0 \message {||}\fi \global \@ignoretrue } %%%%%%%%%%%%%%%%%%%%%%%%%% next token %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \xpa \def \xpa \kill@space \space {% gobble space \futurelet \next@token \test@space } \def \test@space {% check for space \if \space \nxp \next@token \let \next \kill@space \else \let \next \next@command \fi \next } \def \test@@token {\futurelet \next@token \test@space } \let \test@token \test@@token % get next token \def \test@rest {% continue after \control sequence in text \let \test@token \test@@token \xpa \xpa \xpa \test@token \xpa \a@rest \space } %%%%%%%%%%%%%%%%%%%%%%%%%% process Arabic item %%%%%%%%%%%%%%%%%%%%%%%%% \a@digits = {0123456789} \a@paren = {()[]} \a@first = {.^_-'`~,|"=:} % default, scanner dependent \long \def \test@special #1{% check for special cases \if \bgroup \nxp \next@token % arabic group \def \next {\arab@group {#1}}\else \if \nxp #1\relax % command \def \next {\test@command #1}\else \if \nxp <\nxp #1\unarab@codes % Roman insert \let \next \test@insert \else \ifx $#1\unarab@codes % Math insert \let \next \test@math \else \def \next {\test@word #1}% % normal case \fi\fi\fi\fi \next } \def \test@word #1 {% process next Arabic word \ifarab \putwordb@x {\arab@item #1>}\fi \a@spacetrue \show@input #1>\test@token } \def \arab@item #1#2>{% split the word if necessary \ifx \relax #2\relax \arab@write #1>\else % character \ifcat a#1\arab@write #1#2>\else % word \test@in@set #1\a@first \ifin@list \arab@write #1#2>\else % word \test@in@set #1\a@paren \ifin@list \arab@item #2>\arab@space % parenthesis \arab@write #1>\else \test@in@set #1\a@digits \ifin@list \a@split #1#2>\else % number \arab@write #1>\arab@item #2>% % punctuation \fi\fi\fi\fi\fi } %%%%%%%%%%%%%%%%%%%%%% Arabic word %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \arab@write #1>{% process arabic word \a@scan #1>% generate the token sequence \xpa \a@parse \the\a@tokens >% split it into syllables and reverse \xpa \a@write \the\a@revwd >% output the word \ifnum \tracingarab > 2 \message {.}\fi } %%%%%%%%%%%%%%%%%%%%%%%%%% Arabic commands %%%%%%%%%%%%%%%%%%%%%%%%%%%% \gdef \a@c@last@ {\\}\gdef \a@c@put@ {\|}\gdef \a@c@par@ {\par }% \long \def \test@command #1{% check for special commands \gdef \a@arg {#1}\let \next \test@token \ifx \a@arg \a@c@par@ \a@@par \else \ifx \a@arg \a@c@last@ \a@short@line \else \ifx \a@arg \a@c@put@ \a@put@line \else \def \next {\a@command #1}% process the command inside "acmd.sty" \fi\fi\fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% Arabic groups %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \arab@group #1{% process the next group \bgroup \initlineb@x \def \end {\global \setbox1 \hbox {\unhbox \lineb@x}% \egroup \putwordb@x {\unhbox1 }\test@token }% last line \test@token #1 \end } \def \arab@sequence #1>{% put a sequence of words into a \hbox \bgroup \transfalse \showfalse \let \end \relax \let \a@short@line \finish@line \let \a@put@line \break@line \def \next@command {\test@special}\let \put@word \addt@line \initlineb@x \test@token #1 \end \box\lineb@x \egroup } %%%%%%%%%%%%%%%%%%%%%%%%%% arabic number %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@split #1>{% split off any punctuation from the number \def \a@body {}\split@body #1>% \xpa \test@in@set \a@rest \a@digits \ifin@list \arab@digits #1>\else \xpa \arab@write \a@rest >\arab@space \xpa \arab@digits \a@body >\fi } \def \split@body #1#2>{% separate the body and the rest \ifx \relax #2\relax \def \a@rest {#1}\else \edef \a@body {\a@body #1}\split@body #2>\fi } \def \arab@digits #1#2>{% split a digit sequence \arab@write #1>% \ifx \relax #2\relax \else \arab@digits #2>\fi } %%%%%%%%%%%%%%%%%%%%%%%%%% insertions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \test@math #1${% Math insertion in Arabic text \putwordb@x {$#1$}\arab@codes \test@token } \def \test@insert #1>{% Roman insertion in Arabic text \putwordb@x {\rm #1}\arab@codes \test@token } %%%%%%%%%%%%%%%%%%%%%%%%%% verbatim mode %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@verb #1>{\def \verb@text {#1}% list input words verbatim {\penalty \z@ \tt \xpa \get@meaning \meaning \verb@text }\ } \def \get@meaning #1>{} % strip off macro header \def \show@input #1>{% show verbatim text and transliteration \ifshow \a@verb #1>\fi \iftrans {\set@transfont \trans@text #1 \end }\fi } %%%%%%%%%%%%%%%%%%%%%%%%%%%% arabic insertion %%%%%%%%%%%%%%%%%%%%%%%% {\catcode `\< = \@other % better make sure \gdef \<{\protect \a@ins } \gdef \a@ins {% arabic insertion or 'less' \ifmmode \global\let \a@less < \else \global\let \a@less \arab@insert \leavevmode \bgroup \arab@codes \set@arabfont \@waslafalse \@wasfalse \fi \a@less } } % catcode < other {\catcode`\< = \active % prepare active < \gdef <{\protect \a@ins } } % catcode < active \def \break@line {% \| inside insertion \box\lineb@x \break \initlineb@x } \def \finish@line {% \\ inside insertion \box\lineb@x \hfil \break \initlineb@x } \def \arab@insert #1>{% Arabic insertion in Roman text \ifshow \a@verb #1>\fi % verbating listing \ifarab \arab@sequence #1>\fi % arabic writing \iftrans \set@transfont \ \trans@text #1 \end \/\fi \ifnum \tracingarab > 1 \message {>}\fi \unskip \egroup } %%%%%%%%%%%%%%%%%%%%%%%%% transliteration %%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \set@transfont {\rm \it }% font for transliteration \long \def \trans@text #1{% check for special cases \def \next {\trans@text }% \ifx \end #1\let \next \relax \else \ifx \par #1\endgraf \else \ifx \\#1\hfil \break \else \ifx \|#1\hfil \break \else \if \relax \nxp #1\relax % ignore control sequences \else \def \next {\trans@elem #1}% normal case \fi\fi\fi\fi\fi \next } \def \trans@elem #1 {% transliterate next word of text \trans@word #1>\trans@text } \def \trans@word #1>{% transliterate a word \a@scan #1>\xpa \a@trans \the\a@tokens >\ } %%%%%%%%%%%%%%%%%%%%%%% output routines %%%%%%%%%%%%%%%%%%%%%%%%% \def \putwordb@x #1{% deposit a word \ifa@vmode \arab@indent \fi \setbox \wordb@x \hbox {#1}\put@word } \def \putlineb@x #1{% open the line box \ifvmode \vskip \parskip \nointerlineskip \fi \setbox \lineb@x \hbox {#1}\a@vmodefalse } \def \initlineb@x {% make an empty Arabic line \putlineb@x {\arab@strut }\a@spacefalse } \def \arab@indent {% like \indent for Arabic \ifa@vmode \putlineb@x {\hskip \a@parindent \arab@strut }\the\a@@everypar \else \setbox \wordb@x \hbox {\hskip \a@parindent }\add@word \fi \a@spacefalse } \def \arab@noindent {% like \noindent for Arabic \ifa@vmode \initlineb@x \the\a@@everypar \fi } \def \leavea@vmode {% like \leavevmode for Arabic \ifa@vmode \arab@indent \fi } \def \arab@space {\space }% no infinite stretch !! \def \setspace #1{\def \arab@space {\hskip #1\relax }}% redefine ? \def \def@arabstrut {\def \arab@strut {\if@vocals %\vrule height2ex depth1.5ex width\z@ \relax \else \vrule height3ex depth1.5ex width\z@ \relax \else \vrule height2ex depth1.0ex width\z@ \relax \fi }} %%%%%%%%%%%%%%%%%%%%%%% output processing %%%%%%%%%%%%%%%%%%%%%%%%% \newdimen \line@wd \newdimen \wd@wd \def \add@word {% add word to line without space \putlineb@x {\unhbox \wordb@x \unhbox \lineb@x }} \def \addt@line {% add word to line unconditionally, spacing ? \ifa@space \putlineb@x {\unhcopy \wordb@x \arab@space \unhcopy \lineb@x }% \else \add@word \fi } \def \put@word {% add word to line, spacing, break line if necessary \ifa@space \setbox \tempb@x \hbox {\unhcopy \wordb@x \arab@space \unhcopy \lineb@x }% \else \setbox \tempb@x \hbox {\unhcopy \wordb@x \unhcopy \lineb@x }% \fi \ifdim \hsize < \wd\tempb@x \put@line \add@word \else \setbox \lineb@x \box \tempb@x \fi } \def \put@line {\unskip % output the line, adjusted \ifarab \endgraf \parindent \z@ \parskip \z@ \hbox to \hsize {\unhbox \lineb@x }\initlineb@x \fi \ifnum \tracingarab > 1 \message {|}\fi } \iffalse \def \put@line{% put line with adjustment \endgraf \parindent \z@ \parskip \z@ \a@spacefalse \hbox to \hsize {\hskip \rightskip \unhbox \lineb@x \hskip \leftskip }\initlineb@x \ifnum \tracingarab > 1 \message {|}\fi } \fi \def \last@line {\unskip % output the line without adjusting, close line \ifarab \endgraf \parindent \z@ \parskip \z@ \a@par@hook \ifdim \wd\lineb@x = \z@ \else \ifspread \wd@wd \hsize \divide \wd@wd 8 \line@wd \hsize \advance \line@wd -\wd\lineb@x \hbox to \hsize {\loop \hfil \advance \line@wd -\wd@wd \ifdim \line@wd > \z@ \repeat \unhbox \lineb@x }% \else \hbox to \hsize {\hfil \unhbox \lineb@x }% \fi\fi\fi \ifnum \tracingarab > 1 \message {/}\fi } \def \short@line{% put line without adjustment, close line \endgraf \parindent \z@ \parskip \z@ \a@par@hook \a@spacefalse \ifdim \wd\lineb@x = \z@ \else \ifspread \wd@wd \hsize \divide \wd@wd 8 \line@wd \hsize \advance \line@wd -\wd\lineb@x \hbox to \hsize {\hskip \rightskip \loop \hfil \advance \line@wd -\wd@wd \ifdim \line@wd > \z@ \repeat \unhbox \lineb@x \hskip \leftskip }% \else \hbox to \hsize {\hskip \rightskip \hfil \unhbox \lineb@x \hskip \leftskip }% \fi\fi \initlineb@x \ifnum \tracingarab > 1 \message {/}\fi } \iffalse \def \last@line {\short@line \a@vmodetrue } \else \let \short@line \last@line \fi \let \a@par@hook \relax % reserved \def \testoutput {% show output box \showboxbreadth = \maxdimen \showboxdepth = 6 \tracingoutput = 1 } %%%%%%%%%%%%%%%%%%%%%%%%% initialization %%%%%%%%%%%%%%%%%%%%%%%% \def \startarab {% set default initializations \ifx \dospecials \undefined \else \toks0 = \expandafter {\dospecials }% \edef \dospecials {\the\toks0 \noexpand \do <} \fi \transfalse \arabtrue \vocalize \ligstrue \setnash \tracingarab = 3 \setnone } % \catcode < := 12 for user macros \let \a@document \document \def \document {\a@document \setarab } % activate insertions \def \oldarabtex {% patch for catching the old input notation \errhelp {If you continue now, places to change will be marked.}% \errmessage {Obsolete coding; please update your input file.}% \gdef \sc@c {@} \setarab } %%%%%%%%%%%%%%%%%%%%%%% load the later passes %%%%%%%%%%%%%%%%%%%%%% \input acmd.sty % load the command processor module \input afonts.sty % load the default font \input ascan.sty % generate a token sequence \input aparse.sty % parse it into syllables and reverse them \input awrite.sty % generate the basic writing \input aligs.sty % modify for any ligatures %\input bidir.sty % bidirectional linebreaking %\input atrans.sty % generate the transliteration \ifx \LaTeX \undefined \else \input alatex.sty \fi % extensions for LaTeX \ifx \edmacloaded \relax \input aedpatch.sty \fi % patches for EDMAC ? \input apatch.sty % any last minute corrections %%%%%%%%%%%%%%%%%%%%%%% statistics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \wlog {} \wlog {Parameterless commands valid in arabic mode:} \wlog {\space (\the\a@@listzero )} \wlog {} \wlog {Commands with 1 parameter valid in arabic mode:} \wlog {\space (\the\a@@listone )} \wlog {} \wlog {Commands with 2 parameters valid in arabic mode:} \wlog {\space (\the\a@@listtwo )} %%%%%%%%%%%%%%%%%%%%%%%%%%%% here we go %%%%%%%%%%%%%%%%%%%%%%% \catcode`\@ = \arabatcode \startarab \typeout {Arabic processor `ArabTeX' \arabtexversion } \typeout {... now be patient ...} \endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%