From f40cf40f9a59b9c6d214e9fd2d81aac7c4cae45d Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 18 Feb 2022 22:10:18 +0000
Subject: bidi (18feb22)

git-svn-id: svn://tug.org/texlive/trunk@62073 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/xelatex/bidi/bidi.dtx | 769 +++++++++++++++----------
 1 file changed, 460 insertions(+), 309 deletions(-)

(limited to 'Master/texmf-dist/source/xelatex/bidi/bidi.dtx')

diff --git a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
index 5e13b4e12b0..03829a0cb7b 100644
--- a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
+++ b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
@@ -5,7 +5,7 @@
 %<*readme>
 ___________________
 The bidi package
-v36.6
+v36.7
 
 This package provides a convenient interface for typesetting
 bidirectional texts in Plain TeX and LaTeX, using XeTeX engine.
@@ -15,7 +15,7 @@ documentation, or ask for any new features, or suggest any
 improvements, or ask any questions about the package, then
 please use the issue tracker:
 
-  <https://github.com/persiantex/bidi/issues>
+  <https://github.com/tex-persian/bidi/issues>
   
 In doing so, please always explain your issue well enough, 
 and always include a minimal working example showing the 
@@ -30,7 +30,7 @@ The announcements for the new releases of the package will
 also appear in the Discussions space under the Announcements
 category.
   
-Current version release date: 2022/02/13
+Current version release date: 2022/02/18
 
 ___________________________________________
 Vafa Khalighi
@@ -136,6 +136,7 @@ by Vafa Khalighi.
 \generate{\file{floatrow-xetex-bidi.def}{\from{\jobname.dtx}{table,floatrow-xetex-bidi.def}}}
 \generate{\file{flowfram-xetex-bidi.def}{\from{\jobname.dtx}{table,flowfram-xetex-bidi.def}}}
 \generate{\file{footnote-xetex-bidi.def}{\from{\jobname.dtx}{table,footnote-xetex-bidi.def}}}
+\generate{\file{footnotebackref-xetex-bidi.def}{\from{\jobname.dtx}{table,footnotebackref-xetex-bidi.def}}}
 \generate{\file{framed-xetex-bidi.def}{\from{\jobname.dtx}{table,framed-xetex-bidi.def}}}
 \generate{\file{ftnright-xetex-bidi.def}{\from{\jobname.dtx}{table,ftnright-xetex-bidi.def}}}
 \generate{\file{graphicx-xetex-bidi.def}{\from{\jobname.dtx}{table,graphicx-xetex-bidi.def}}}
@@ -150,6 +151,7 @@ by Vafa Khalighi.
 \generate{\file{listings-xetex-bidi.def}{\from{\jobname.dtx}{table,listings-xetex-bidi.def}}}
 \generate{\file{loadingorder-xetex-bidi.def}{\from{\jobname.dtx}{table,loadingorder-xetex-bidi.def}}}
 \generate{\file{longtable-xetex-bidi.def}{\from{\jobname.dtx}{table,longtable-xetex-bidi.def}}}
+\generate{\file{lscape-xetex-bidi.def}{\from{\jobname.dtx}{table,lscape-xetex-bidi.def}}}
 \generate{\file{mathtools-xetex-bidi.def}{\from{\jobname.dtx}{table,mathtools-xetex-bidi.def}}}
 \generate{\file{mdframed-xetex-bidi.def}{\from{\jobname.dtx}{table,mdframed-xetex-bidi.def}}}
 \generate{\file{bidi-media9.sty}{\from{\jobname.dtx}{table,bidi-media9.sty}}}
@@ -164,6 +166,7 @@ by Vafa Khalighi.
 \generate{\file{ntheorem-hyper-xetex-bidi.def}{\from{\jobname.dtx}{table,ntheorem-hyper-xetex-bidi.def}}}
 \generate{\file{overpic-xetex-bidi.def}{\from{\jobname.dtx}{table,overpic-xetex-bidi.def}}}
 \generate{\file{pdfbase-xetex-bidi.def}{\from{\jobname.dtx}{table,pdfbase-xetex-bidi.def}}}
+\generate{\file{pdflscape-xetex-bidi.def}{\from{\jobname.dtx}{table,pdflscape-xetex-bidi.def}}}
 \generate{\file{pdfpages-xetex-bidi.def}{\from{\jobname.dtx}{table,pdfpages-xetex-bidi.def}}}
 \generate{\file{pgfcorescopes.code-xetex-bidi.def}{\from{\jobname.dtx}{table,pgfcorescopes.code-xetex-bidi.def}}}
 \generate{\file{picinpar-xetex-bidi.def}{\from{\jobname.dtx}{table,picinpar-xetex-bidi.def}}}
@@ -234,7 +237,7 @@ by Vafa Khalighi.
 \documentclass{ltxdoc}
 \input{bidi-doc-preamble.ltx}
 \hypersetup{%
-  pdftitle={Source documentation for version 36.6 of the bidi
+  pdftitle={Source documentation for version 36.7 of the bidi
                 package}%
 }
 \EnableCrossrefs
@@ -253,7 +256,7 @@ by Vafa Khalighi.
 % \GetFileInfo{\jobname.dtx}
 % \title{\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}\\
 %\LARGE Bidirectional typesetting in plain \TeX{} and \LaTeX, using \XeTeX{} engine\\[5pt]
-%\large Source documentation for \textcolor{blue!65!black}{version 36.6}}
+%\large Source documentation for \textcolor{blue!65!black}{version 36.7}}
 % \author{Vafa Khalighi\thanks{Thanks to the bidi-tex GitHub organization consisted of David Carlisle and other members of the  {\LaTeX} team to maintain the package in the period 2018--2020.}\\
 %  \url{tex-persian@vafa.ac}}
 %\setcounter{page}{0}
@@ -264,7 +267,7 @@ by Vafa Khalighi.
 %\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}
 %
 %\Large
-%Source documentation for \textcolor{blue!65!black}{version 36.6}}
+%Source documentation for \textcolor{blue!65!black}{version 36.7}}
 %
 %\vskip 0pt plus 3fill
 %\textit{\large to my Master, \textbf{Ferdowsi The Great}}
@@ -313,7 +316,7 @@ by Vafa Khalighi.
 %\iffalse
 %<*table>
 %\fi
-%% \CheckSum{50439}
+%% \CheckSum{50574}
 %% \CharacterTable
 %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
 %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -1933,8 +1936,8 @@ by Vafa Khalighi.
 % \section{File \texttt{bidi.sty}}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\def\bididate{2022/02/13}
-\def\bidi@version{36.6}
+\def\bididate{2022/02/18}
+\def\bidi@version{36.7}
 \ProvidesPackage{bidi}[\bididate\space v\bidi@version\space
 Bidirectional typesetting in plain TeX and LaTeX]
 \edef\@bidi@info{****************************************************^^J%
@@ -2024,7 +2027,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 }
 \newcommand*{\@bidi@pdfcustomproperties}{%
   This is the bidi package, Version \bidi@version,
-  Released February 13, 2022. 
+  Released February 18, 2022. 
 }
 \@RTLmainfalse
 \AtBeginDocument{%
@@ -2267,9 +2270,9 @@ Bidirectional typesetting in plain TeX and LaTeX]
 %\fi
 % \section{File \texttt{bidi.tex}}
 %    \begin{macrocode}
-\def\bididate{2022/02/13}
+\def\bididate{2022/02/18}
 \catcode`@=11
-\def\bidi@version{36.6}
+\def\bidi@version{36.7}
 \let \protect \relax
 \newlinechar`\^^J
 \edef\@bidi@info{****************************************************^^J%
@@ -2373,7 +2376,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 }
 \def\@bidi@pdfcustomproperties{%
   This is the bidi package, Version \bidi@version,
-  Released February 13, 2022. 
+  Released February 18, 2022. 
 }
 \def\bidi@pdfm@mark{%
   \special{pdf:%
@@ -8200,7 +8203,7 @@ bidi implementation of tufte title]
 %\fi
 % \section{File \texttt{cuted-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{cuted-xetex-bidi.def}[2017/05/06 v0.6 bidi adaptations for cuted package for XeTeX engine]
+\ProvidesFile{cuted-xetex-bidi.def}[2022/02/18 v0.7 bidi adaptations for cuted package for XeTeX engine]
 
 \def\RTL@outputdblcol{%
   \if@firstcolumn
@@ -8324,263 +8327,280 @@ bidi implementation of tufte title]
     \endgroup
   \fi}%
 
-
-\def \@addviper {%
-   \if@firstcolumn
-     \@insertfalse
-     \@reqcolroom .5\@pageht
-     \ht@viper\@reqcolroom
-     \advance \@reqcolroom \ht\@viper
-     \advance \@reqcolroom \stripsep
-     \ifvoid\hold@viper\@tempdima=\z@\else\@tempdima\ht\hold@viper\fi
-%%
-     \@tempdimb \ht@viper
-     \loop
-     \setbox\v@aaa\copy\@holdpg
-     \setbox\v@ccc\vbox to\@tempdimb{%
-                \vsplit\v@aaa to\@tempdimb\vss\vsplit\v@aaa to\@tempdimb}%
-     \wlog{Extra height:\the\ht\v@aaa\space when \the\@tempdimb}%
-     \ifvoid\v@aaa \else \advance\@tempdimb 1pt \repeat
-     \loop
-     \setbox\v@aaa\copy\@holdpg
-     \setbox\v@ccc\vbox to\@tempdimb{%
-                \vsplit\v@aaa to\@tempdimb\vss}%
-     \wlog{(2)Left:\the\ht\v@ccc\space Right:\the\ht\v@aaa\space Output:\the\@tempdimb}%
-     \ifdim \ht\v@ccc<\ht\v@aaa \@tempdimb \the\ht\v@aaa \repeat
-     \wlog{- LAST -^^JLeft:\the\ht\v@ccc^^JRight:\the\ht\v@aaa^^JOutput:\the\@tempdimb}%
-     \setbox\v@ccc\vbox to\@tempdimb{%
-                \vsplit\@holdpg to\@tempdimb\vss}%
-%%
-     \setbox\@tempboxa \vbox {%
-        \hb@xt@\textwidth {%
-          \if@RTLmain%
-          \hskip \columnwidth
-           \hfil \vrule width\columnseprule \hfil
-            \hb@xt@\columnwidth {%
-                    \vbox to\ht@viper{\box\v@ccc\vss} \hss}%
-             \hskip -\textwidth
-             \hb@xt@\columnwidth {%
-                    \vbox to\ht@viper{\box\@holdpg\vss} \hss}%
-              \hskip \columnsep
-              \hskip \columnwidth
-               \else%
-                \hb@xt@\columnwidth {%
-                    \vbox to\ht@viper{\box\v@ccc\vss} \hss}%
-                    \hfil
-                    \vrule \@width\columnseprule
-                    \hfil
-                    \hb@xt@\columnwidth {%
-                    \vbox to\ht@viper{\box\@holdpg\vss} \hss}%
-                          \fi}%
-                       }%
-     \ifvoid\hold@viper
-        \global\setbox\hold@viper \vbox {%
-                \unvbox\@tempboxa
-                \penalty\interlinepenalty
-                \vskip\stripsep
-                \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
-                \outputpenalty \z@
-                        }%
-     \else
-        \global\setbox\hold@viper \vbox {%
-                \unvbox\hold@viper
-                \unvbox\@tempboxa
-                \penalty\interlinepenalty
-                \vskip\stripsep
-                \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
-                \outputpenalty \z@
+\def\@addviper{%
+    \@insertfalse
+    \def\var@@thecol@num{2}%
+    \if@firstcolumn
+        \def\var@@thecol@num{1}%
+        \@reqcolroom=.5\@pageht
+        \ht@viper=\@reqcolroom
+        \advance\@reqcolroom by\ht\@viper
+        \advance\@reqcolroom by\stripsep
+    \else
+        \@reqcolroom=\@colht
+        \advance\@reqcolroom by\@pageht
+        \ht@viper.5\@reqcolroom
+        \@reqcolroom=\ht@viper
+        \advance\@reqcolroom by\ht\@viper
+        \advance\@reqcolroom by\stripsep
+        \global\setbox\@holdpg\vbox{%
+            \setbox\cuted@@tempbox@a\vbox{%
+                \aftergroup\unvbox
+                \unvcopy\@leftcolumn
+                \unskip\unkern\unpenalty
+                \setbox\@tempboxa\lastbox
+                \ifdim\dimexpr\ht\@tempboxa+\wd\@tempboxa+\dp\@tempboxa>\z@
+                    %% keeps lastbox
+                    \aftergroup\@leftcolumn
+                \else
+                    %% removes lastbox
+                    \aftergroup\cuted@@tempbox@a
+                \fi
+                }%
+            \unskip\unkern\unpenalty
+            \on@stripcols@break
+            \the\At@ViperColsBreak
+            \unvbox\@holdpg
+            }%
+        \global\At@ViperColsBreak{}%
+        \ht@viper=.5\ht\@holdpg
+        \ifdim\ht@viper>\@colht
+            \ht@viper=\@colht
+        \fi
+    \fi
+    %%
+    %% calculations for breaking
+    %%
+    \ifvoid\hold@viper
+        \ht@hold@viper=\z@
+    \else
+        \ht@hold@viper=\ht\hold@viper
+    \fi
+    \cuted@@tempdim@b\ht@viper
+    \set@split@topskip@to\topskip
+    \loop
+        \xdef\saved@tempdimb{\the\cuted@@tempdim@b}%
+        \setbox\cuted@@varbox@a\copy\@holdpg
+        \setbox\cuted@@tempbox@a\vsplit\cuted@@varbox@a to\cuted@@tempdim@b
+        %% set leftcolumn boxes
+        \setbox\cuted@@tempbox@c\vbox{\unvbox\cuted@@tempbox@a}%
+        \setbox\cuted@@tempbox@a\vbox to\cuted@@tempdim@b{\unvcopy\cuted@@tempbox@c}%
+        \xdef\var@@leftcolumn@badness{\the\badness}%
+        %% set rightcolumn boxes
+        \setbox\cuted@@varbox@c\vbox{\unvbox\cuted@@varbox@a}%
+        \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@b{\unvcopy\cuted@@varbox@c}%
+        \xdef\var@@rightcolumn@badness{\the\badness}%
+        %% analyzing split goodness
+        \cuted@@tempdim@spread=\ht\cuted@@tempbox@c
+        \advance\cuted@@tempdim@spread by\dp\cuted@@tempbox@c
+        \advance\cuted@@tempdim@spread by-\ht\cuted@@varbox@c
+        \advance\cuted@@tempdim@spread by-\dp\cuted@@varbox@c
+        \cuted@@wlog@debug{CUTED [-----]%
+              ^^JLeft: \the\ht\cuted@@tempbox@c
+              +\the\dp\cuted@@tempbox@c\space/\var@@leftcolumn@badness
+              ^^JRight: \the\ht\cuted@@varbox@c
+              +\the\dp\cuted@@varbox@c\space/\var@@rightcolumn@badness
+              ^^JSplit: \the\cuted@@tempdim@b
+              ^^JExtra height: \the\cuted@@tempdim@spread
+             }%
+        \ifnum\var@@leftcolumn@badness<\cuted@@column@badness
+            \ifnum\var@@rightcolumn@badness<\cuted@@column@badness
+                \cuted@@tempdim@spread=\z@
+            \fi
+        \fi
+        \ifdim\cuted@@tempdim@spread<\z@
+            \if@left@column@spread
+                \if@right@column@shrink
+                    \ifdim\dimexpr\cuted@@tempdim@spread+\pageshrink>\z@
+                        \cuted@@tempdim@a=\dimexpr\ht\cuted@@tempbox@c-0.5\cuted@@tempdim@spread\relax
+                    \else
+                        \cuted@@tempdim@a=-\dimexpr\cuted@@tempdim@spread+.5\pageshrink\relax
+                    \fi
+                    \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@a{\unvcopy\cuted@@tempbox@c}%
+                    \ifnum\badness<\cuted@@column@badness
+                        \cuted@@tempdim@b=\cuted@@tempdim@a
+                        \cuted@@tempdim@spread=\z@
+                    \fi
+                    \cuted@@wlog@debug{CUTED [leftcolumn badness]: \number\badness\space on \the\cuted@@tempdim@a}%
+                    \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@a{\unvcopy\cuted@@varbox@c}%
+                    \cuted@@wlog@debug{CUTED [rightcolumn badness]: \number\badness\space on \the\cuted@@tempdim@a}%
+                \else
+                    \setbox\cuted@@varbox@a\vbox to\ht\cuted@@varbox@c{%
+                        \unvcopy\cuted@@tempbox@c
                         }%
-     \fi
-     \ifdim \@colroom>\@reqcolroom
-        \global\setbox\hold@viper \vbox {%
-                \unvbox\hold@viper
-                \box\@viper
-                \penalty\interlinepenalty
-                \vskip\stripsep
-                \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
-                \outputpenalty \z@
+                    \ifnum\badness<\cuted@@column@badness
+                        \@tempdimb=\ht\cuted@@varbox@c
+                        \cuted@@tempdim@spread=\z@
+                    \fi
+                    \cuted@@wlog@debug{CUTED [leftcolumn badness]: \number\badness on \the\ht\cuted@@varbox@c}%
+                    \setbox\cuted@@varbox@a\vbox to\ht\cuted@@varbox@c{%
+                        \unvcopy\cuted@@varbox@c
                         }%
-        \@inserttrue
-        \advance\@tempdima by-\ht\hold@viper
-        \global \advance \@colht \@tempdima
-        \ifdim \@colht<2.5\baselineskip
-           \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
-                too tall on page \thepage (1 stulpelis)}%
-           \@emptycol
-           \if@firstcolumn
-           \else
-             \@emptycol
-           \fi
-           \global\@lastvipertrue
+                    \cuted@@wlog@debug{CUTED [rightcolumn badness]: \number\badness on \the\ht\cuted@@varbox@c}%
+                \fi
+            \else
+                \if@right@column@shrink
+                    \ifdim\dimexpr\cuted@@tempdim@spread+\pageshrink<\z@
+                    \else
+                        \cuted@@tempdim@b=\ht\cuted@@tempbox@c
+                        \cuted@@tempdim@spread=\z@
+                    \fi
+                \fi
+            \fi
         \else
-           \global \vsize \@colht
-           \global \@colroom \@colht
-           \check@floats
-           \ifdim\@tempdima>\z@
-                   \global\advance\@colroom by-\@tempdima
-           \fi
-           \ifdim\@colroom<\z@
-                   \global\@colroom 1pt
-                   \ifdim\@tempdima>\@colht
-                      \@latex@warning@no@line {TOP ir/ar BOT FLOAT's
-                                 netelpa lape \thepage (1 stulpelis)}%
-                   \fi
-                   \@emptycol
-                   \if@firstcolumn
-                   \else
-                     \@emptycol
-                   \fi
-                   \global\@lastvipertrue
-           \fi
+            \ifdim\cuted@@tempdim@spread>\z@
+                \ifdim\dimexpr\@tempdimb+\p@\relax>\@colht
+                    \cuted@@tempdim@b=\@colht
+                    \cuted@@tempdim@spread=\z@
+                \fi
+            \fi
         \fi
-     \fi
-   \else
-     \@insertfalse
-     \@reqcolroom\@colht
-     \advance\@reqcolroom \@pageht
-     \ht@viper.5\@reqcolroom
-     \@reqcolroom\ht@viper
-     \advance \@reqcolroom \ht\@viper
-     \advance \@reqcolroom \stripsep
-      \if@flushend@auto@baselineskip
-        \setbox\@tempboxa\vbox{\unvcopy\@leftcolumn
-          \global\lastskip@d\lastskip
-          \global\lastskip@b\lastskip
-          \loop
-            \global\lastskip@a\lastskip@b
-            \unskip\unpenalty
-            \global\lastskip@b\lastskip
-            \global\advance\lastskip@d by\lastskip
-          \ifdim\lastskip@b=-\lastskip@a
-            \global\advance\lastskip@d by-\lastskip
-          \else
-          \repeat
-          \ifdim\lastskip@b=-\lastskip@a
-            \ifdim\lastskip@b=\z@
-              \setbox\lastbox@a\lastbox
-              \global\advance\lastskip@d by\ht\lastbox@a
-              \global\advance\lastskip@d by\lastskip
-              \unskip\unpenalty
-              \setbox\lastbox@a\lastbox
-              \global\advance\lastskip@d by\dp\lastbox@a
+    \ifdim\cuted@@tempdim@spread<\z@
+        \advance\cuted@@tempdim@b 1\p@
+    \repeat
+    \wlog{CUTED [- LAST -]%
+          ^^JExtra skip:\the\cuted@@tempdim@spread
+          ^^JLeft:\the\ht\cuted@@tempbox@c/\the\dp\cuted@@tempbox@c
+          ^^JRight:\the\ht\cuted@@varbox@c/\the\dp\cuted@@varbox@c
+          ^^JSplit: \saved@tempdimb
+          ^^JOutput:\the\cuted@@tempdim@b
+          ^^JPageshrink: \the\pageshrink
+          ^^JPagestretch: \the\pagestretch
+          ^^J@colht:\the\@colht
+          }%
+    %%
+    %% final construction of the cuted page above strip
+    %%
+    \setbox\cuted@@tempbox@c\vsplit\@holdpg to\saved@tempdimb
+    \setbox\cuted@@tempbox@a\vbox to\cuted@@tempdim@b{%
+        \cuted@@tempdim@a=\dimexpr
+            \cuted@@tempdim@b-\ht\cuted@@tempbox@c
+            \relax
+        \cuted@@tempdim@spread=\dp\cuted@@tempbox@c
+        \unvbox\cuted@@tempbox@c
+        \ifdim\cuted@@tempdim@spread>\dp\strutbox
+        \else
+            \vskip-\cuted@@tempdim@spread
+        \fi
+        \prevdepth\z@
+        \hrule\@height\cuted@@page@rule width\textwidth
+        \vskip-\cuted@@page@rule
+        \ifdim\cuted@@tempdim@a>\z@
+            \if@left@column@spread
             \else
-              \global\lastskip@d\lastskip
-              \global\advance\lastskip@d by\topskip
+                \vss
             \fi
-          \fi
-          \global\advance\lastskip@d by-\topskip
-          }%
-       \ifdim\ht\@holdpg>\@colht
-         \global\setbox\@holdpg\vbox{\unvbox\@leftcolumn\unskip\unpenalty
-           \par\eject
-           \vbox to \@colht{\unvbox\@holdpg\unskip}%
-           }%
-       \else
-         \global\setbox\@holdpg\vbox{%
-           \unvbox\@leftcolumn\unskip\unpenalty
-           \vskip\lastskip@d
-           \the\At@ViperColsBreak
-           \unvbox\@holdpg
-           \unskip
-           }%
-       \fi
-     \else
-       \global\setbox\@holdpg\vbox{%
-                \unvbox\@leftcolumn
-                \setbox\@tempboxa\lastbox
-                \on@stripcols@break
-                \the\At@ViperColsBreak
-                \unvbox\@holdpg
-                }%
-     \fi
-     \global\At@ViperColsBreak{}%
-     \ht@viper .5\ht\@holdpg
-     \ifdim \ht@viper>\@colht
-        \ht@viper \@colht
-     \fi
-     \ifvoid\hold@viper\@tempdima=\z@\else\@tempdima\ht\hold@viper\fi
-%%
-     \@tempdimb \ht@viper
-     \loop
-       \setbox\v@aaa\copy\@holdpg
-       \setbox\v@ccc\vbox to\@tempdimb{%
-                \vsplit\v@aaa to\@tempdimb
+        \else
+            \ifdim\cuted@@tempdim@a<\z@
+                \if@left@column@shrink
+                \else
+                    \vss
+                \fi
+            \fi
+        \fi
+        }%
+    \wlog{CUTED [output]: \the\cuted@@tempdim@b
+          ^^JCUTED [leftcolumn badness]: \number\badness
+         }%
+    \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@b{%
+        \cuted@@tempdim@a=\dimexpr
+            \cuted@@tempdim@b-\ht\@holdpg
+            \relax
+        \unvbox\@holdpg
+        \ifdim\cuted@@tempdim@a>\z@
+            \if@right@column@spread
+            \else
                 \vss
-                \vsplit\v@aaa to\@tempdimb
-                }%
-       \wlog{Extra height:\the\ht\v@aaa\space when \the\@tempdimb}%
-     \ifvoid\v@aaa
-     \else
-       \advance\@tempdimb 1\p@
-     \repeat
-     \loop
-       \setbox\v@aaa\copy\@holdpg
-       \setbox\v@ccc\vbox to\@tempdimb{\vsplit\v@aaa to\@tempdimb\vss}%
-       \wlog{(2)Left:\the\ht\v@ccc\space
-               Right:\the\ht\v@aaa\space
-              Output:\the\@tempdimb
-            }%
-     \ifdim\ht\v@ccc<\ht\v@aaa
-       \@tempdimb \the\ht\v@aaa
-     \repeat
-     \wlog{- LAST -^^JLeft:\the\ht\v@ccc
-                  ^^JRight:\the\ht\v@aaa
-                 ^^JOutput:\the\@tempdimb
-          }%
-     \setbox\v@ccc\vbox to\@tempdimb{\vsplit\@holdpg to\@tempdimb\vss}%
-     \setbox\@tempboxa\vbox{%
-        \hb@xt@\textwidth {%
-           \if@RTLmain%
-           \hskip \columnwidth
-           \hfil \vrule width\columnseprule \hfil
-           \hb@xt@\columnwidth{\vbox to\ht@viper{\box\v@ccc\vss} \hss}%
-           \hskip -\textwidth
-           \hb@xt@\columnwidth {\vbox to\ht@viper{\box\@holdpg\vss} \hss}%
-           \hskip \columnsep
-           \hskip \columnwidth
+            \fi
+        \else
+            \ifdim\cuted@@tempdim@a<\z@
+                \if@right@column@shrink
+                \else
+                    \vss
+                \fi
+            \fi
+        \fi
+        }%
+    \wlog{CUTED [rightcolumn badness]: \number\badness}%
+    \setbox\cuted@@tempbox@var\vbox{%
+        \hb@xt@\textwidth{%
+           \if@RTLmain
+              \hskip \columnwidth
+              \hfil
+              {\normalcolor\vrule \@width\columnseprule}%
+              \hfil
+              \hb@xt@\columnwidth{%
+                 \vbox to\ht@viper{\box\cuted@@tempbox@a\vss}%
+                 \hss
+              }%
+              \hskip -\textwidth
+              \hb@xt@\columnwidth{%
+                 \vbox to\ht@viper{\box\cuted@@varbox@a\vss}%
+                 \hss
+              }%
+              \hskip \columnsep
+              \hskip \columnwidth
            \else
-            \hb@xt@\columnwidth{\vbox to\ht@viper{\box\v@ccc\vss} \hss}%
-            \hfil
-            \vrule \@width\columnseprule
-            \hfil
-            \hb@xt@\columnwidth {\vbox to\ht@viper{\box\@holdpg\vss} \hss}%
-           \fi%
+              \hb@xt@\columnwidth{%
+                 \vbox to\ht@viper{\box\cuted@@tempbox@a\vss}%
+                 \hss
+              }%
+              \hfil
+              {\normalcolor\vrule \@width\columnseprule}%
+              \hfil
+              \hb@xt@\columnwidth{%
+                 \vbox to\ht@viper{\box\cuted@@varbox@a\vss}%
+                 \hss
+              }%
+           \fi
             }%
         }%
-     \ifvoid\hold@viper
-        \global\setbox\hold@viper \vbox {%
-                \unvbox\@tempboxa
-                \penalty\interlinepenalty
-                \vskip\stripsep
-                \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
-                \outputpenalty \z@
-                        }%
-     \else
-        \global\setbox\hold@viper \vbox {%
-                \unvbox\hold@viper
-                \unvbox\@tempboxa
-                \penalty\interlinepenalty
-                \vskip\stripsep
-                \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
-                \outputpenalty \z@
-                        }%
-     \fi
-     \ifdim \@colht>\@reqcolroom
-        \global\setbox\hold@viper \vbox {%
-                \unvbox\hold@viper
-                \box\@viper
-                \penalty\interlinepenalty
-                \vskip\stripsep
-                \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
-                \outputpenalty \z@
-                        }%
+    %%
+    %% finalize cuted page
+    %%
+    \ifvoid\hold@viper
+        \global\setbox\hold@viper\vbox{%
+            \unvbox\cuted@@tempbox@var
+            \penalty\interlinepenalty
+            \vskip\stripsep
+            \the\preCutedStrip
+            \ifnum\outputpenalty<-\@Mii
+                \vskip -\parskip
+            \fi
+            \outputpenalty\z@
+            }%
+    \else
+        \global\setbox\hold@viper\vbox{%
+             \unvbox\hold@viper
+             \cuted@@tempbox@var
+             \penalty\interlinepenalty
+             \vskip\stripsep
+             \the\preCutedStrip
+             \ifnum\outputpenalty<-\@Mii
+                 \vskip -\parskip
+             \fi
+             \outputpenalty\z@
+             }%
+    \fi
+    \ifdim\@colht>\@reqcolroom
+        \global\setbox\hold@viper\vbox{%
+             \unvbox\hold@viper
+             \box\@viper
+             \penalty\interlinepenalty
+             \the\postCutedStrip
+             \vskip\stripsep
+             \ifnum\outputpenalty<-\@Mii
+                 \vskip -\parskip
+             \fi
+             \outputpenalty\z@
+             }%
         \@inserttrue
         \global\@firstcolumntrue
-        \advance\@tempdima by-\ht\hold@viper
-        \global \advance \@colht \@tempdima
-        \ifdim \@colht<2.5\baselineskip
+        \advance\ht@hold@viper by-\ht\hold@viper
+        \global\advance\@colht by\ht@hold@viper
+        \ifdim\@colht<2.5\baselineskip
             \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
-                                     too tall on page \thepage (2 stulpelis)}%
+                                     too tall on page \thepage (\var@@thecol@num column)}%
             \@emptycol
             \if@firstcolumn
             \else
@@ -8588,17 +8608,17 @@ bidi implementation of tufte title]
             \fi
             \global\@lastvipertrue
         \else
-            \global \vsize \@colht
-            \global \@colroom \@colht
-            \check@floats
-            \ifdim\@tempdima>\z@
-                \global\advance\@colroom by-\@tempdima
+            \global\vsize\@colht
+            \global\@colroom\@colht
+            \check@floats\cuted@@tempdim@a
+            \ifdim\cuted@@tempdim@a>\z@
+                \global\advance\@colroom by-\cuted@@tempdim@a
             \fi
             \ifdim\@colroom<\z@
-                \global\@colroom 1pt
-                \ifdim\@tempdima>\@colht
-                \@latex@warning@no@line {TOP ir/ar BOT FLOAT's
-                                 netelpa lape \thepage (2 stulpelis)}%
+                \global\@colroom1\p@
+                \ifdim\cuted@@tempdim@a>\@colht
+                    \@latex@warning@no@line{TOP and/or BOT FLOAT's
+                        to large on \thepage (\var@@thecol@num column)}%
                 \fi
                 \@emptycol
                 \if@firstcolumn
@@ -8608,23 +8628,22 @@ bidi implementation of tufte title]
                 \global\@lastvipertrue
             \fi
         \fi
-      \fi
-  \fi
-  \if@insert
-  \else
-      \advance\@tempdima by-\ht\hold@viper
-      \global \advance \@colht \@tempdima
-      \global\setbox\hold@viper \vbox {%
-                                       \unvbox\hold@viper
-                                       \csname viper@top@hook\endcsname
-                                       \vsplit\@viper to \@colht
-                                       \vss
-                                      }%
-      \vbox{}%
-      \global\@firstcolumnfalse
-      \newpage
-  \fi
-  }
+    \fi
+    \if@insert
+    \else
+        \advance\ht@hold@viper by-\ht\hold@viper
+        \global\advance\@colht by\ht@hold@viper
+        \global\setbox\hold@viper\vbox{%
+            \unvbox\hold@viper
+            \set@split@topskip@to{\z@ plus2\p@}%
+            \vsplit\@viper to\@colht
+            \vss
+            }%
+        \vbox{}%
+        \global\@firstcolumnfalse
+        \newpage
+    \fi
+    }
 %    \end{macrocode}
 % \iffalse
 %</cuted-xetex-bidi.def>
@@ -9157,7 +9176,7 @@ bidi implementation of tufte title]
 %\fi
 % \section{File \texttt{eso-pic-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{eso-pic-xetex-bidi.def}[2022/02/01 v0.3 bidi adaptations for eso-pic package for XeTeX engine]
+\ProvidesFile{eso-pic-xetex-bidi.def}[2022/02/18 v0.4 bidi adaptations for eso-pic package for XeTeX engine]
 \renewcommand\AtPageLowerLeft[1]{\AtPageUpperLeft{%
   \put(\if@RTLmain\paperwidth\else 0\fi,-\paperheight){#1}}}
 
@@ -9165,15 +9184,25 @@ bidi implementation of tufte title]
   \renewcommand\AtTextUpperLeft[1]{%
     \begingroup
       \ifodd\c@page
-        \ESO@tempdima=\spinemargin
+        \if@RTLmain
+          \ESO@tempdima=\paperwidth
+          \advance\ESO@tempdima-\textwidth
+          \advance\ESO@tempdima-\spinemargin
+        \else
+          \ESO@tempdima=\spinemargin
+        \fi
       \else
-        \ESO@tempdima=\paperwidth
-        \advance\ESO@tempdima-\textwidth
-        \advance\ESO@tempdima-\spinemargin
+        \if@RTLmain
+          \ESO@tempdima=\spinemargin
+        \else
+          \ESO@tempdima=\paperwidth
+          \advance\ESO@tempdima-\textwidth
+          \advance\ESO@tempdima-\spinemargin
+        \fi
       \fi
       \ESO@tempdimb=-\uppermargin
       \AtPageUpperLeft{%
-        \put(\if@RTLmain-\fi\ESO@tempdima,\ESO@tempdimb){#1}%
+        \put(\if@RTLmain-\textwidth-\fi\ESO@tempdima,\ESO@tempdimb){#1}%
       }%
     \endgroup
   }
@@ -9203,7 +9232,7 @@ bidi implementation of tufte title]
       \advance\ESO@tempdimb-\headheight
       \advance\ESO@tempdimb-\headsep
       \AtPageUpperLeft{%
-        \put(\if@RTLmain-\fi\ESO@tempdima,\ESO@tempdimb){#1}%
+        \put(\if@RTLmain-\textwidth-\fi\ESO@tempdima,\ESO@tempdimb){#1}%
       }%
     \endgroup
   }
@@ -12407,6 +12436,80 @@ bidi implementation of tufte title]
 %    \end{macrocode}
 % \iffalse
 %</footnote-xetex-bidi.def>
+%<*footnotebackref-xetex-bidi.def>
+%\fi
+% \section{File \texttt{footnotebackref-xetex-bidi.def}}
+%    \begin{macrocode}
+\ProvidesFile{footnotebackref-xetex-bidi.def}[2022/02/18 v0.1 bidi adaptations for footnotebackref package for XeTeX engine]
+\LetLtxMacro{\BHFN@OldLTRFootnote}{\LTRfootnote}
+\LetLtxMacro{\BHFN@OldRTLFootnote}{\RTLfootnote}
+
+\renewcommand*\LTRfootnote{%
+    \refstepcounter{BackrefHyperFootnoteCounter}%
+    \edef\BackrefFootnoteTag{bhfn:\theBackrefHyperFootnoteCounter}%
+    \label{\BackrefFootnoteTag}%
+    \@ifnextchar[\Backref@OptLTRHyperFootnote\Backref@HyperLTRFootnote}
+    
+\renewcommand*\RTLfootnote{%
+    \refstepcounter{BackrefHyperFootnoteCounter}%
+    \edef\BackrefFootnoteTag{bhfn:\theBackrefHyperFootnoteCounter}%
+    \label{\BackrefFootnoteTag}%
+    \@ifnextchar[\Backref@OptRTLHyperFootnote\Backref@HyperRTLFootnote}
+\newcommand\Backref@HyperLTRFootnote[1]{%
+    \BHFN@OldLTRFootnote{\Backref@HyperSymbol#1}}
+    
+\newcommand\Backref@HyperRTLFootnote[1]{%
+    \BHFN@OldRTLFootnote{\Backref@HyperSymbol#1}}
+    
+\newcommand\Backref@OptHyperLTRFootnote[2][\empty]{%
+    \BHFN@OldLTRFootnote[#1]{\Backref@HyperSymbol#2}}
+    
+\newcommand\Backref@OptHyperRTLFootnote[2][\empty]{%
+    \BHFN@OldRTLFootnote[#1]{\Backref@HyperSymbol#2}}
+    
+\bidi@AfterFile{extrafootnotefeatures-xetex-bidi.def}{%
+\ifFootnoteBackref@numberlinked
+\renewcommand{\footfootmark}{%
+  \ifdim\footmarkwidth < \z@
+    \llap{\hb@xt@ -\footmarkwidth{%
+            \hss\normalfont\footscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+          \hspace*{-\footmarkwidth}}%
+  \else
+    \ifdim\footmarkwidth = \z@
+      {\normalfont\footscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+    \else
+      \hb@xt@\footmarkwidth{\hss\normalfont\footscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+    \fi
+  \fi}
+\renewcommand{\LTRfootfootmark}{%
+  \ifdim\footmarkwidth < \z@
+    \llap{\hb@xt@ -\footmarkwidth{%
+            \hss\normalfont\LTRfootscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+          \hspace*{-\footmarkwidth}}%
+  \else
+    \ifdim\footmarkwidth = \z@
+      {\normalfont\LTRfootscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+    \else
+      \hb@xt@\footmarkwidth{\hss\normalfont\LTRfootscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+    \fi
+  \fi}
+\renewcommand{\RTLfootfootmark}{%
+  \ifdim\footmarkwidth < \z@
+    \llap{\hb@xt@ -\footmarkwidth{%
+            \hss\normalfont\RTLfootscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+          \hspace*{-\footmarkwidth}}%
+  \else
+    \ifdim\footmarkwidth = \z@
+      {\normalfont\RTLfootscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+    \else
+      \hb@xt@\footmarkwidth{\hss\normalfont\RTLfootscript{\hyperref[\BackrefFootnoteTag]{\@thefnmark}}}%
+    \fi
+  \fi}
+\fi
+}
+%    \end{macrocode}
+% \iffalse
+%</footnotebackref-xetex-bidi.def>
 %<*framed-xetex-bidi.def>
 %\fi
 % \section{File \texttt{framed-xetex-bidi.def}}
@@ -14854,6 +14957,39 @@ bidi implementation of tufte title]
 %    \end{macrocode}
 % \iffalse
 %</longtable-xetex-bidi.def>
+%<*lscape-xetex-bidi.def>
+%\fi
+% \section{File \texttt{lscape-xetex-bidi.def}}
+%    \begin{macrocode}
+\ProvidesFile{lscape-xetex-bidi.def}[2022/02/18 v0.1 bidi adaptations for lscape package for XeTeX engine]
+\bidi@patchcmd{\LS@rot}{\rotatebox{90}{\box\@outputbox}}{%
+  \if@RTL
+    \rotatebox[origin=br]{-90}{\box\@outputbox}%
+  \else
+    \rotatebox{90}{\box\@outputbox}%
+  \fi
+}{}{}
+\g@addto@macro{\landscape}{%
+  \let\bidi@left@footnoterule\left@footnoterule
+  \let\bidi@right@footnoterule\right@footnoterule
+  \def\left@footnoterule{%
+    \if@RTL
+      \bidi@right@footnoterule
+    \else
+      \bidi@left@footnoterule
+    \fi
+  }%
+  \def\right@footnoterule{%
+    \if@RTL
+      \bidi@left@footnoterule
+    \else
+      \bidi@right@footnoterule
+    \fi
+  }%
+}
+%    \end{macrocode}
+% \iffalse
+%</lscape-xetex-bidi.def>
 %<*mathtools-xetex-bidi.def>
 %\fi
 % \section{File \texttt{mathtools-xetex-bidi.def}}
@@ -14955,7 +15091,7 @@ bidi implementation of tufte title]
 %\fi
 % \section{File \texttt{bidi-media9.sty}}
 %    \begin{macrocode}
-\ProvidesExplPackage{bidi-media9}{2017/08/27}{0.3}
+\ProvidesExplPackage{bidi-media9}{2022/02/18}{0.4}
 {bidi fixes for media9 package for the XeTeX engine}
 
 \keys_define:nn{media9/mbtn}{
@@ -14986,7 +15122,7 @@ bidi implementation of tufte title]
     \regex_replace_once:nnN{([^:]+):??.*}{\1}\l_tmpa_tl
     \tl_trim_spaces:N\l_tmpa_tl
     \tl_if_exist:cTF{ann@\l_tmpa_tl}{
-      \str_if_eq_x:nnF{\tl_use:c{ann@\l_tmpa_tl}}{draft}{
+      \str_if_eq:eeF{\tl_use:c{ann@\l_tmpa_tl}}{draft}{
         \tl_set:Nx\l_tmpb_tl{#1}          %extract idx
         \regex_replace_once:nnN{[^:]+:?}{}\l_tmpb_tl
         \tl_trim_spaces:N\l_tmpb_tl
@@ -15037,7 +15173,7 @@ bidi implementation of tufte title]
     \regex_replace_once:nnN{([^:]+):??.*}{\1}\l_tmpa_tl %extract ref
     \tl_trim_spaces:N\l_tmpa_tl
     \tl_if_exist:cTF{ann@\l_tmpa_tl}{
-      \str_if_eq_x:nnF{\tl_use:c{ann@\l_tmpa_tl}}{draft}{
+      \str_if_eq:eeF{\tl_use:c{ann@\l_tmpa_tl}}{draft}{
         \tl_set:Nx\l_tmpb_tl{#1}
         \regex_replace_once:nnN{[^:]+\:?}{}\l_tmpb_tl
         \tl_trim_spaces:N\l_tmpb_tl
@@ -15109,7 +15245,7 @@ bidi implementation of tufte title]
     \bool_lazy_and:nnT{
       \tl_if_exist_p:c{ann@\l_tmpa_tl}
     }{
-      !\str_if_eq_x_p:nn{\tl_use:c{ann@\l_tmpa_tl}}{draft}
+      !\str_if_eq_p:ee{\tl_use:c{ann@\l_tmpa_tl}}{draft}
     }{
       \mix_pdfobj:nnn{}{dict}{
         /S/JavaScript/JS~(
@@ -15127,7 +15263,7 @@ bidi implementation of tufte title]
       \bool_lazy_and_p:nn{
         \tl_if_exist_p:c{ann@\l_tmpa_tl}
       }{
-        !\str_if_eq_x_p:nn{\tl_use:c{ann@\l_tmpa_tl}}{draft}
+        !\str_if_eq_p:ee{\tl_use:c{ann@\l_tmpa_tl}}{draft}
       }
       || !\tl_if_blank_p:V\l_tmpb_tl
     }{
@@ -15145,7 +15281,7 @@ bidi implementation of tufte title]
   \mix_uriend:
   \group_begin:
   \mix_beginLTR:
-  \leavevmode
+  \mode_leave_vertical:
   %empty stream as appearance dummy
   \cs_if_exist:NF\g_mix_appearance_tl{
     \hbox_set:Nn\l_mix_poster_box{\phantom{\rule{1pt}{1pt}}}
@@ -15218,7 +15354,7 @@ bidi implementation of tufte title]
       \bool_gset_true:N\g_mix_iiid_bool
       \tl_gset:Nn\g_mix_mainassetsub_tl{3D}
     }{
-      \str_case_x:nnF{\l_mix_base_tl}{
+      \str_case_e:nnF{\l_mix_base_tl}{
         {APlayer}{\tl_gset:Nn\g_mix_mainassetsub_tl{Sound}}
         {AudioPlayer}{\tl_gset:Nn\g_mix_mainassetsub_tl{Sound}}
         {VPlayer}{\tl_gset:Nn\g_mix_mainassetsub_tl{Video}}
@@ -15241,7 +15377,7 @@ bidi implementation of tufte title]
     }
     %create 3D views from file (option 3Dviews)
     \bool_if:nT{\g_mix_iiid_bool && !(\tl_if_blank_p:V\g_mix_vfile_tl)}{
-      \tl_set:Nn\l_mix_level_tl{\c_minus_one}
+      \tl_set:Nn\l_mix_level_tl{-1}
       \int_zero:N\l_mix_viewcnt_int
       \int_zero:N\l_mix_lineno_int
 
@@ -15358,7 +15494,7 @@ bidi implementation of tufte title]
               /Height~<</Default~\tl_mix_fltht>>
               /Position~<<
                 /HOffset~0/VOffset~0
-                \str_case_x:nnF{\g_mix_winpos_tl}{
+                \str_case_e:nnF{\g_mix_winpos_tl}{
                   {tl}{/VAlign/Near/HAlign/Near}
                   {cl}{/VAlign/Center/HAlign/Near}
                   {bl}{/VAlign/Far/HAlign/Near}
@@ -15412,7 +15548,7 @@ bidi implementation of tufte title]
             annotRM['\g_mix_label_tl']=
               this.getAnnotRichMedia(this.pageNum,'\g_mix_label_tl');
           }
-          \str_if_eq_x:nnF{\g_mix_usrpbtn_tl}{none}{
+          \str_if_eq:eeF{\g_mix_usrpbtn_tl}{none}{
             if(typeof(ocgBtn\int_use:N\g_mix_rmcnt_int)=='undefined'){
               var~ocgs=this.getOCGs(this.pageNum);
               for(var~i=0;i<ocgs.length;i++){
@@ -15444,7 +15580,7 @@ bidi implementation of tufte title]
     }
     \mix_appendtofields:n{\mix_pdflastann:}
     \hbox_overlap_right:n{\box_use:N\l_mix_poster_box}
-    \str_if_eq_x:nnTF{\g_mix_usrpbtn_tl}{none}{
+    \str_if_eq:eeTF{\g_mix_usrpbtn_tl}{none}{
       \hbox_to_wd:nn{\g_mix_wd_tl}{
         \vrule~width~\c_zero_dim~height~\g_mix_ht_tl~depth~\g_mix_dp_tl\hss
       }
@@ -15478,7 +15614,7 @@ bidi implementation of tufte title]
   \mix_uriend:
   \group_begin:
   \mix_beginLTR:
-  \leavevmode
+  \mode_leave_vertical:
   %reset various variables
   \tl_gclear:N\g_mix_overbtn_tl
   \tl_gclear:N\g_mix_downbtn_tl
@@ -15537,7 +15673,6 @@ bidi implementation of tufte title]
 \tl_set_eq:NN\l_mix_mediabutton_tl\mediabutton
 \tl_set:Nn\mediabutton{\mix_uribegin:\l_mix_mediabutton_tl}
 
-
 %    \end{macrocode}
 % \iffalse
 %</bidi-media9.sty>
@@ -16489,14 +16624,11 @@ bidi implementation of tufte title]
 %\fi
 % \section{File \texttt{pdfbase-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{pdfbase-xetex-bidi.def}[2020/05/13 v0.3 bidi adaptations for pdfbase package for XeTeX engine]
+\ProvidesFile{pdfbase-xetex-bidi.def}[2022/02/18 v0.4 bidi adaptations for pdfbase package for XeTeX engine]
 \ExplSyntaxOn
 \cs_set_eq:NN\pbs_outputpage_orig:\@outputpage
 \cs_set_nopar:Npn\@outputpage{
   \int_gincr:N\g_pbs_page_int
-  \iow_now:Nx\@mainaux{
-    \token_to_str:N\pbs@newkey{pbs@last@page}{\int_use:N\g_pbs_page_int}
-  }
   \box_if_vertical:cTF{@outputbox}{
     \bool_set_true:N\l_pbs_is_vertical_bool
   }{
@@ -16518,6 +16650,21 @@ bidi implementation of tufte title]
 %    \end{macrocode}
 % \iffalse
 %</pdfbase-xetex-bidi.def>
+%<*pdflscape-xetex-bidi.def>
+%\fi
+% \section{File \texttt{pdflscape-xetex-bidi.def}}
+%    \begin{macrocode}
+\ProvidesFile{pdflscape-xetex-bidi.def}[2022/02/18 v0.1 bidi adaptations for pdflscape package for XeTeX engine]
+\bidi@patchcmd{\landscape}{\PLS@Rotate{90}}{%
+  \if@RTL
+    \PLS@Rotate{-90}%
+  \else
+    \PLS@Rotate{90}%
+  \fi
+}{}{}
+%    \end{macrocode}
+% \iffalse
+%</pdflscape-xetex-bidi.def>
 %<*pdfpages-xetex-bidi.def>
 %\fi
 % \section{File \texttt{pdfpages-xetex-bidi.def}}
@@ -22079,7 +22226,7 @@ to\rtside{\box\bslice\hfil}}
 %\fi
 % \section{File \texttt{latex-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{latex-xetex-bidi.def}[2022/02/13 v1.3.9 bidi adaptations  for `latex.ltx' for XeTeX engine]
+\ProvidesFile{latex-xetex-bidi.def}[2022/02/18 v1.4.0 bidi adaptations  for `latex.ltx' for XeTeX engine]
 \newcommand{\TeXXeTOn}{\TeXXeTstate\@ne}
 \newcommand{\TeXXeTOff}{\TeXXeTstate\z@}
 \TeXXeTOn
@@ -22923,6 +23070,7 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
   \input{mathtools-xetex-bidi.def}%
   }{}
 \@ifpackageloaded{crop}{\RequirePackage{graphicx}}{}
+\@ifpackageloaded{lscape}{\RequirePackage{graphicx}}{}
 \@ifpackageloaded{sidecap}{\RequirePackage{ragged2e}}{}
 \@ifpackageloaded{floatrow}{\RequirePackage{color}}{}
 \@ifpackageloaded{algorithm2e}{\input{algorithm2e-xetex-bidi.def}}{}
@@ -22956,7 +23104,9 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
 \@ifpackageloaded{ntheorem}{\input{ntheorem-xetex-bidi.def}}{}
 \@ifpackageloaded{tabularx}{\input{tabularx-xetex-bidi.def}}{}
 \@ifpackageloaded{longtable}{\input{longtable-xetex-bidi.def}}{}
+\@ifpackageloaded{lscape}{\input{lscape-xetex-bidi.def}}{}
 \@ifpackageloaded{hyperref}{\input{hyperref-xetex-bidi.def}}{}
+\@ifpackageloaded{footnotebackref}{\input{footnotebackref-xetex-bidi.def}}{}
 \@ifpackageloaded{ntheorem-hyper}{\input{ntheorem-hyper-xetex-bidi.def}}{}
 \@ifpackageloaded{fancybox}{\input{fancybox-xetex-bidi.def}}{}
 \@ifpackageloaded{fancyhdr}{\input{fancyhdr-xetex-bidi.def}}{}
@@ -22971,6 +23121,7 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
 \@ifpackageloaded{framed}{\input{framed-xetex-bidi.def}}{}
 \@ifpackageloaded{overpic}{\input{overpic-xetex-bidi.def}}{}
 \@ifpackageloaded{pdfbase}{\input{pdfbase-xetex-bidi.def}}{}
+\@ifpackageloaded{pdflscape}{\input{pdflscape-xetex-bidi.def}}{}
 \@ifpackageloaded{pdfpages}{\input{pdfpages-xetex-bidi.def}}{}
 \@ifpackageloaded{lettrine}{\input{lettrine-xetex-bidi.def}}{}
 \@ifpackageloaded{lineno}{\input{lineno-xetex-bidi.def}}{}
-- 
cgit v1.2.3

