<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% abidir.sty
% ArabTeX macros for bidirectional linebreaking
% 03.09.2000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) Klaus Lagally
%     Institut fuer Informatik
%     Universitaet Stuttgart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifx \a@RL \undefined \else \xpa \endinput \fi

\a@ident {abidir.sty} {3.10 bidirectional linebreaking} {03.09.2000}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% &lt;LR insertion inside Rtext&gt;
%\def \test@insert #1&gt;{\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	
\newbox \a@Rboxi	\newbox \a@Rboxii	\newbox \Rinsertb@x	
\newbox \a@Rdummyi	\newbox \a@Rdummyii	\newbox \Linsertb@x	
\newbox \a@spacebox	\newif \ifR@split	\newcount \a@lines

\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
%\lineskiplimit -2pt	% enforce uniform baselines
\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 &gt; \@ne \message {&gt;}\fi
\unskip \egroup }

\def \a@Rinsert #1{% put a sequence of RL words into Ltext
\leavevmode % go to hmode if not there already
\ifinner \a@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 
\ifspread \else \def \arab@space {\space }% no infinite stretch !!
	\def \tat@skip {0.04ex plus 0.5ex }%
\fi
  \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
\setbox\a@Rboxii \hbox {}\setbox\a@Rdummyii \box\a@Rboxii
\a@Rfirst #1 \to \a@wordi \a@Rrest
\xpa \a@Rwordtobox \a@wordi \to \a@Rboxi \a@Rdummyi
\ifx \space \a@Rrest \else
\if \relax \a@Rrest \relax \else 
\xpa \a@Rfirst \a@Rrest \to \a@wordii \a@Rrest 
\xpa \a@Rwordtobox \a@wordii \to \a@Rboxii \a@Rdummyii 
\fi\fi }

\def \a@Rwordtobox #1\to #2#3{% Rword to \box#2, Rdummy to \box#3
\a@sequence {#1}\setbox#2 \lastbox 
\setbox#3\hbox to \wd#2{\hfill }\ht#3\ht#2\dp#3\z@}

{\catcode `\^^a0 12 
\gdef \a@Rfirst #1 #2\to #3#4{% split off first word
\ifx \relax #1\relax \a@Rfirsti #2\to #3#4\else 
\ifx \relax #2\relax \a@Rfirstii #1^^a0\to #3#4\else 
\def #3{#1}\def #4{#2}\fi\fi }

\gdef \a@Rfirstii #1^^a0#2\to #3#4{% split off first word
\ifx \relax #1\relax \a@Rfirstiii #2\to #3#4\else 
\def #3{#1}\def #4{#2 }\fi }
}% catcode ^^a0

\def \a@Rfirsti #1\to #2#3{% split off leading space
\ifx \relax #1\relax \def #2{\relax }\def #3{\relax }%
\else \a@Rfirst #1\to #2#3\fi }

\def \a@Rfirstiii #1\to #2#3{% split off leading RL space
\ifx \relax #1\relax \def #2{\relax }\def #3{\relax }%
\else \a@Rfirstii #1\to #2#3\fi }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \a@Ldimen {% get the dimensions of the preceding line
\setbox\a@spacebox \hbox {\arab@space}\tolerance 10000
\R@splitfalse \leavevmode 
\penalty 0
\copy \a@Rdummyi \arab@space \copy \a@Rdummyii
\parfillskip \z@ plus 1fill \relax \tr@ceoff 
$$\global \a@Llength \predisplaysize % 		dummy display
\global \a@Lwidth \displaywidth \global \a@Lindent \displayindent 
\hbox to \a@Lwidth {}\postdisplaypenalty \@M
$$ {\endgraf }% keep paragraph parameters
\tr@ceon \a@lines \prevgraf \advance \a@lines -3 
\prevgraf \a@lines \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 
\ifnum \prevgraf = 1
	\ifdim \z@ &gt; \hangindent \advance \a@Llength -\hangindent 
	\else \advance \a@Llength \hangindent 
	\fi
\else 	\ifdim \a@Llength = \z@ \R@splittrue \a@Llength \a@Lwidth 
	\fi
\fi }

\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@ &gt; \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@normpen #1{% prevent penalty 10000
\ifnum #1= 10000 #1= 9999 \fi }

\def \a@Rtobox #1{% pack the insertion into \Rinsertb@x
\setbox \Rinsertb@x \vbox {\a@hsize \a@Lwidth 
\a@normpen \widowpenalty \a@normpen \clubpenalty
\leftskip \z@ \rightskip \z@ 
\parfillskip \z@ plus 1fil \relax \parskip \z@
\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 \Rinsertb@x \repeat \unpenalty \ins@skip }

\def \a@Rgetline {% unpack the next line globally to \box \tempb@x
{\vbadness 10000 \splittopskip \a@vglue 
\dimen0 \baselineskip \advance \dimen0 1ex 
\setbox \tempb@x \vsplit \Rinsertb@x to \dimen0
\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@@Linsert {#1}\a@Lunpack \putwordb@x {\ins@skip }\arab@codes 
\a@spacetrue \test@token }

\def \a@@Linsert #1{% splice Ltext into RL paragraph
\putwordb@x {\ins@skip }\a@spacefalse \dimen0 \wd \lineb@x 
\setbox \Linsertb@x \vbox {\parskip \z@ \tolerance 10000
\a@normpen \widowpenalty \a@normpen \clubpenalty
\hangindent -\dimen0 \hangafter -\@ne \tr@ceoff \rm \tr@ceon
\rightskip \z@ plus .001fil \vskip \a@vglue \noindent 
\null \hskip 0pt plus .001fil \relax #1\par }}

\def \a@Lunpack {% unpack all lines from the insertion
\loop \a@Lgetline 
\putwordb@x {\unhbox \tempb@x \unskip \unskip }\a@spacefalse 
\ifvbox \Linsertb@x \repeat }

\def \a@Lgetline {% unpack the next line globally to \box \tempb@x
{\vbadness 10000 \splittopskip \a@vglue 
\dimen0 \baselineskip \advance \dimen0 1ex 
\setbox \tempb@x \vsplit \Linsertb@x to \dimen0
\setbox0 \vbox {\unvbox \tempb@x \global \setbox \tempb@x \lastbox }}}

%\testoutput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
</pre></body></html>