%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % abidir.sty % ArabTeX macros for bidirectional linebreaking % 21.12.95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (c) Klaus Lagally % Institut fuer Informatik % Universitaet Stuttgart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifx \bidiratcode \undefined \else \xpa \endinput \fi \chardef \bidiratcode = \catcode`\@ \catcode`\@ = 11 \a@ident {abidir.sty} {3.04 bidirectional linebreaking } {21.12.95} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %\def \test@insert #1>{\a@Linsert {#1}} % \LR{#1} = LR insertion inside Rtext \def \a@c@LR {\unarab@codes \a@Linsert } \let \a@c@L \a@c@LR % usage: \L {LR text} % \LR{#1} = LR insertion inside Ltext: trivial \let \LR \relax \let \L \relax %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \RL{#1} = RL insertion inside Ltext \def \RL {\protect \a@RL } \let \R \RL % usage: \R {RL text} % \RL{#1} = RL insertion inside Rtext: trivial \def \a@c@RL #1{\test@token #1 } \let \a@c@R \a@c@RL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \goodpar {% usage: \goodpar {Roman paragraphs} % put around one or more paragraphs if the linebreaking is bad % caution: may lead to storage overflow \dimen0 \prevdepth \setbox0 \vbox \bgroup \prevdepth \dimen0 \def \par {\egroup \endgraf \goodpar x}% dummy character \aftergroup \g@@dpar \let \next=} \def \g@@dpar {\unvbox0 } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newdimen \a@Llength \newdimen \a@Lwidth \newdimen \a@Lindent \newdimen \a@Rlength \newdimen \a@Rheight \newdimen \a@splitht \newbox \insertb@x \newbox \a@spacebox \newbox \a@Rboxi \newbox \a@Rboxii \newbox \a@Rdummyi \newbox \a@Rdummyii \newif \ifR@split \newdimen \a@baselineskip \def \ins@skip {\hskip \z@ plus 0.1em }% before and after insertion \def \a@vglue {\z@ plus 2ex }% glue at top of the insertion \vbox %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@RL {% RL insertion inside Ltext \bgroup \arab@codes \set@arabfont \@waslafalse \@wasfalse \a@@Rinsert } \def \a@@Rinsert #1{% RL insertion inside Ltext \ifshow \a@verb #1>\fi % verbating listing \ifarab \a@Rinsert {#1} \fi % arabic writing \iftrans \set@transfont \trans@text #1 \end \/\fi \ifnum \tracingarab > \@ne \message {>}\fi \unskip \egroup } \def \a@Rinsert #1{% put a sequence of RL words into Ltext \leavevmode % go to hmode if not there already \ifinner \arab@sequence #1>% inside a \hbox: append \else \a@Rsplit {#1}% splice into the current paragraph \fi } \def \a@Rsplit #1{% splice RL words into the current paragraph \bgroup \def \next@command {\test@special}\transfalse \showfalse \def \arab@space {\space }% no infinite stretch !! \a@splitht 3.5ex \def \tat@skip {0.04ex plus 0.5ex }% \a@Rdimen {#1}% get the length of the first 2 RL words \ifdim \wd\a@Rboxii = \z@ \unhbox\a@Rboxi % done with the insertion \else \a@Ldimen % get the dimensions of the last line \a@Rtobox {#1}% pack the insertion lines into a \vbox \a@Runpack % unpack and splice into the current paragraph \fi \egroup } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@Rdimen #1{% get the dimensions of the first two words \a@Rfirst #1 \to \a@wordi \a@Rrest \xpa \a@Rwordtobox \a@wordi \to \a@Rboxi \a@Rdummyi \xpa \ifx \xpa \relax \a@Rrest \relax \def \a@wordii {}% \else \xpa \a@Rfirst \a@Rrest \to \a@wordii \a@Rrest \fi \xpa \a@Rwordtobox \a@wordii \to \a@Rboxii \a@Rdummyii } \def \a@Rwordtobox #1\to #2#3{% Rword to \box#2, Rdummy to \box#3 \setbox#2\hbox {\spreadtrue \arab@strut \arab@sequence #1>% \setbox0 \lastbox \unhbox0 }% \setbox#3\hbox to \wd#2{\hfill }\ht#3\ht#2\dp#3\z@} \def \a@Rfirst #1 #2\to #3#4{% split off first word \ifx \relax #1\relax \ifx \relax #2\relax \def #3{#1}\def #4{#2}\else \a@Rfirst #2 \to #3#4\fi \else \def #3{#1}\def #4{#2}\fi } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@Ldimen {% get the dimensions of the preceding line \setbox\a@spacebox \hbox {\arab@space}\tolerance 10000 \R@splitfalse \leavevmode \copy \a@Rdummyi \arab@space \copy \a@Rdummyii \parfillskip \z@ plus 1fill $$\global \a@Llength \predisplaysize % dummy display \global \a@Lwidth \displaywidth \global \a@Lindent \displayindent \hbox to \a@Lwidth {}\postdisplaypenalty \@M $$ {\endgraf }% keep paragraph parameters \prevdepth -\baselineskip \a@Ladjust % update \a@Llength and \a@Lindent \ifinner \a@killdisplay \else \a@skipback \fi } \def \a@Ladjust {% correct \a@Llength and \a@Lindent \ifdim \a@Llength = \maxdimen \a@Llength \a@Lwidth % flexible line \else \advance \a@Llength -2em \advance \a@Llength -\a@Lindent \fi \advance \a@Llength -\leftskip \advance \a@Llength -\wd\a@Rdummyii \ifdim \a@Llength = \z@ \R@splittrue \a@Llength \a@Lwidth \advance \a@Llength -\leftskip \advance \a@Llength -\rightskip \else \advance \a@Llength -\wd\a@spacebox \fi \advance \a@Llength -\wd\a@Rdummyi } \def \a@killdisplay {% vbox: get back to the old position \unskip \unskip \unpenalty \setbox0 \lastbox % get rid of garbage \ifR@split \unskip \unskip \unpenalty \setbox0 \lastbox \fi \unskip \unskip \unpenalty \setbox0 \lastbox % last line \dimen0 \baselineskip \advance \dimen0 -\ht0 \advance \dimen0 -\lastskip \prevdepth \dimen0 \unskip \vskip -\parskip \noindent \unhbox0 % open and trim last line \unskip \unskip \unpenalty \setbox0 \lastbox \ifR@split \else \unskip \setbox0 \lastbox \fi } \def \a@skipback {% paragraph: get back to the old position \vskip -\belowdisplayskip \vskip -3\baselineskip \vskip -\abovedisplayskip \vskip -\parskip \ifR@split \ifdim \z@ > \lineskiplimit \vskip -\baselineskip \else \vskip -\ht\a@Rdummyii \vskip -\dp\a@Rboxi \vskip -\lineskip \fi\fi \noindent \arab@strut \nobreak \hskip \a@Llength } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@Rtobox #1{% pack the insertion into \insertb@x \setbox \insertb@x \vbox {\a@hsize \a@Lwidth \advance \a@hsize -\leftskip \advance \a@hsize -\rightskip \a@limit \a@hsize \leftskip \z@ \rightskip \z@ \parfillskip \z@ plus 1fil \relax \parskip \z@ \def \arab@space {\nobreak \space }% no infinite stretch !! \let \a@@kern \a@kern \let \a@@mkern \a@mkern \def \a@kern {\nobreak \a@@kern}\def \a@mkern {\nobreak \a@@mkern}% \let \end \relax \spreadtrue \vskip \a@vglue \hbadness 10000 \putlineb@x {\arab@strut \hskip \a@Llength }\a@spacefalse \test@token #1 \end \unskip \unskip \vskip \a@vglue \hbox {\box\lineb@x \hfill }}} \def \a@Runpack {\ins@skip % unpack all lines from the insertion \loop \a@Rgetline \unhbox \tempb@x \unskip \unskip \break \ifvbox \insertb@x \repeat \unpenalty \ins@skip } \def \a@Rgetline {% unpack the next line globally to \box \tempb@x \splittopskip \a@vglue \setbox \tempb@x \vsplit \insertb@x to \a@splitht \setbox0 \vbox {\unvbox \tempb@x \setbox2 \lastbox \unhbox2 \unskip \unskip \unpenalty \global \setbox \tempb@x \lastbox }} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \a@Linsert #1{% splice Ltext into RL paragraph \a@spacetrue \putwordb@x {\ins@skip }\dimen0 \wd \lineb@x \setbox \insertb@x \vbox {\rm \parskip \z@ \hangindent -\dimen0 \hangafter -\@ne \rightskip \z@ plus .001fil \vskip \a@vglue \noindent #1\par }% \a@splitht 3.5ex \a@Lunpack \putwordb@x {\ins@skip }% \a@spacetrue \arab@codes \test@token } \def \a@Lunpack {% unpack all lines from the insertion \loop \a@getline \a@spacefalse \putwordb@x {\unhbox \tempb@x \unskip \unskip }% \ifvbox \insertb@x \repeat } \def \a@getline {% unpack the next line globally to \box \tempb@x \splittopskip \a@vglue \setbox \tempb@x \vsplit \insertb@x to \a@splitht \setbox0 \vbox {\unvbox \tempb@x \global \setbox \tempb@x \lastbox }} \catcode`\@ = \bidiratcode %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endinput