From 7b61510c53b104577fa7804435895594da6bd884 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 7 Oct 2018 21:08:27 +0000
Subject: bidi (7oct18)

git-svn-id: svn://tug.org/texlive/trunk@48852 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/xelatex/bidi/bidi.dtx | 907 ++++++++-----------------
 1 file changed, 289 insertions(+), 618 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 ceee92003db..78a15bfd96e 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
-v34.4
+v34.6
 
 This package provides a convenient interface for typesetting
 bidirectional texts in Plain TeX and LaTeX, using XeTeX engine.
@@ -44,7 +44,7 @@ mailing list whenever I have time. You can subscribe to the mailing list at
   <http://tug.org/mailman/listinfo/persiantex>
   
   
-Current version release date: 2018/10/04
+Current version release date: 2018/10/08
 
 ___________________
 Vafa Khalighi
@@ -242,7 +242,7 @@ by Vafa Khalighi.
 \documentclass{ltxdoc}
 \input{bidi-doc-preamble.ltx}
 \hypersetup{%
-  pdftitle={Source documentation for version 34.4 of the bidi
+  pdftitle={Source documentation for version 34.6 of the bidi
                 package}%
 }
 \EnableCrossrefs
@@ -261,7 +261,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 34.4}}
+%\large Source documentation for \textcolor{blue!65!black}{version 34.6}}
 % \author{Vafa Khalighi\\
 %  \url{persian-tex@tug.org}}
 %\setcounter{page}{0}
@@ -272,7 +272,7 @@ by Vafa Khalighi.
 %\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}
 %
 %\Large
-%Source documentation for \textcolor{blue!65!black}{version 34.4}}
+%Source documentation for \textcolor{blue!65!black}{version 34.6}}
 %
 %\vskip 0pt plus 3fill
 %\textit{\large to my Master, \textbf{Ferdowsi The Great}}
@@ -338,7 +338,7 @@ by Vafa Khalighi.
 %\iffalse
 %<*table>
 %\fi
-%% \CheckSum{50675}
+%% \CheckSum{49977}
 %% \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
@@ -1951,8 +1951,8 @@ by Vafa Khalighi.
 % \section{File \texttt{bidi.sty}}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\def\bididate{2018/10/04}
-\def\bidi@version{34.4}
+\def\bididate{2018/10/08}
+\def\bidi@version{34.6}
 \ProvidesPackage{bidi}[\bididate\space v\bidi@version\space
 Bidirectional typesetting in plain TeX and LaTeX]
 \edef\@bidi@info{****************************************************^^J%
@@ -2016,6 +2016,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 \newcommand*{\setnonlatin}{\@nonlatintrue}
 \eqnewif{\if@RTLtab}{\if@tab@rl}
 \newif\if@hboxRconstruct
+\newif\if@bidi@pdfencrypt
 \newcommand*{\setRTLtable}{\@RTLtabtrue}
 \newcommand*{\setLTRtable}{\@RTLtabfalse}
 \newif\if@bidi@pdfm@mark
@@ -2024,7 +2025,6 @@ Bidirectional typesetting in plain TeX and LaTeX]
 \newif\if@LTRbibitems
 \newif\if@RTLbibitems
 \newif\if@extrafootnotefeatures
-\newif\if@parafootRTL
 \newif\if@RTLcolumnfootnotes
 \eqnewif{\if@RTL@footnote}{\if@rl@footnote}
 \newif\if@bidi@list@minipage@parbox
@@ -2037,7 +2037,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 }
 \newcommand*{\@bidi@pdfcustomproperties}{%
   This is the bidi package, Version \bidi@version,
-  Released October 1, 2018. 
+  Released October 8, 2018. 
 }
 \@RTLmainfalse
 \AtBeginDocument{%
@@ -2237,12 +2237,23 @@ Bidirectional typesetting in plain TeX and LaTeX]
     \RequirePackage{bidi-perpage}%
     \ResetCounterPerPage{footnote}%
   \fi
-  \special{pdf:encrypt
-    userpw (\bidi@pdfencrypt@userpassword)
-    ownerpw (\bidi@pdfencrypt@ownerpassword)
-    length \bidi@pdfencrypt@keylength
-    perm \bidi@pdfencrypt@permissionflags
-  }%
+  \ifx\bidi@pdfencrypt@ownerpassword\bidi@empty
+    \ifx\bidi@pdfencrypt@userpassword\bidi@empty
+      \@bidi@pdfencryptfalse
+    \else
+      \@bidi@pdfencrypttrue
+    \fi
+  \else
+    \@bidi@pdfencrypttrue 
+  \fi
+  \if@bidi@pdfencrypt
+    \special{pdf:encrypt
+      userpw (\bidi@pdfencrypt@userpassword)
+      ownerpw (\bidi@pdfencrypt@ownerpassword)
+      length \bidi@pdfencrypt@keylength
+      perm \bidi@pdfencrypt@permissionflags
+    }%
+  \fi
 }
 \AtEndDocument{%
    \special{pdf:%
@@ -2265,9 +2276,9 @@ Bidirectional typesetting in plain TeX and LaTeX]
 %\fi
 % \section{File \texttt{bidi.tex}}
 %    \begin{macrocode}
-\def\bididate{2018/10/04}
+\def\bididate{2018/10/08}
 \catcode`@=11
-\def\bidi@version{34.4}
+\def\bidi@version{34.6}
 \let \protect \relax
 \newlinechar`\^^J
 \edef\@bidi@info{****************************************************^^J%
@@ -2366,7 +2377,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 }
 \def\@bidi@pdfcustomproperties{%
   This is the bidi package, Version \bidi@version,
-  Released October 1, 2018. 
+  Released October 8, 2018. 
 }
 \def\bidi@pdfm@mark{%
   \special{pdf:%
@@ -9534,7 +9545,9 @@ bidi implementation of tufte title]
 %\fi
 % \section{File \texttt{extrafootnotefeatures-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{extrafootnotefeatures-xetex-bidi.def}[2018/09/27 v1.4 bidi extra footnote features for XeTeX engine]
+\ProvidesFile{extrafootnotefeatures-xetex-bidi.def}[2018/10/08 v1.6 bidi extra footnote features for XeTeX engine]
+\newif\if@bidi@void@footins
+\newif\if@bidi@void@@mpfootins
 \newcommand*{\@bidi@before@Hy@hyperfootnotes}{%
 \if@bidi@csundef{ifHy@hyperfootnotes}{}{%
 \if@bidi@csundef{HLTR@@LTRfootnotetext}{}{%
@@ -9576,8 +9589,28 @@ bidi implementation of tufte title]
 \let\LRfootnoterule\relax
 \def\footnoterule{\kern-3\p@
   \hrule \@width \columnwidth \kern 2.6\p@}
-\bidi@ensure@newcommand{\setRTLparagraphfootnotes}{\@parafootRTLtrue}
-\bidi@ensure@newcommand{\setLTRparagraphfootnotes}{\@parafootRTLfalse}
+\newcommand{\@preamnormalfmt}{%
+  \parindent 1em%
+  \noindent
+} 
+\newcommand{\@normalfootfmt}[1]{%
+  \@preamnormalfmt
+  \footfootmark
+  \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
+  \@finalstrut\strutbox
+}
+\newcommand{\@normalRTLfootfmt}[1]{%
+  \@preamnormalfmt
+  \RTLfootfootmark
+  \rule\z@\footnotesep\ignorespaces{\RTLfoottextfont #1}%
+  \@finalstrut\strutbox
+}
+\newcommand{\@normalLTRfootfmt}[1]{%
+  \@preamnormalfmt
+  \LTRfootfootmark
+  \rule\z@\footnotesep\ignorespaces{\LTRfoottextfont #1}%
+  \@finalstrut\strutbox
+}
 \renewcommand{\@footnotetext}[1]{%
     \insert\footins{%
     \if@RTL@footnote\@RTLtrue\else\@RTLfalse\fi%
@@ -9589,9 +9622,7 @@ bidi implementation of tufte title]
     \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark}%
     \color@begingroup
-      \@makefntext{%
-        \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
-        \@finalstrut\strutbox}%
+      \@normalfootfmt{#1}%
     \color@endgroup}%    
       \m@mmf@prepare}
 \renewcommand{\@RTLfootnotetext}[1]{%
@@ -9605,9 +9636,7 @@ bidi implementation of tufte title]
     \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark}%
     \color@begingroup
-      \@makefntext{%
-        \rule\z@\footnotesep\ignorespaces{\RTLfoottextfont #1}%
-        \@finalstrut\strutbox}%
+      \@normalRTLfootfmt{#1}%
     \color@endgroup}%    
       \m@mmf@prepare}
 \renewcommand{\@LTRfootnotetext}[1]{%
@@ -9621,49 +9650,41 @@ bidi implementation of tufte title]
     \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark}%
     \color@begingroup
-      \@makefntext{%
-        \rule\z@\footnotesep\ignorespaces{\LTRfoottextfont #1}%
-        \@finalstrut\strutbox}%
+      \@normalLTRfootfmt{#1}%
     \color@endgroup}%    
       \m@mmf@prepare}
 \renewcommand{\@mpfootnotetext}[1]{%
   \global\setbox\@mpfootins\vbox{\if@RTL@footnote\@RTLtrue\else\@RTLfalse\fi%
     \unvbox\@mpfootins
     \def\baselinestretch{\m@m@footnote@spacing}%
+    \reset@font%
     \foottextfont \hsize\columnwidth \@parboxrestore
     \protected@edef\@currentlabel{%
       \csname p@mpfootnote\endcsname\@thefnmark}%
   \color@begingroup
-  \reset@font%
-    \@makefntext{%
-      \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
-      \@finalstrut\strutbox}%
+    \@normalfootfmt{#1}%
   \color@endgroup}}
 \renewcommand{\@mpLTRfootnotetext}[1]{%
   \global\setbox\@mpfootins\vbox{\@RTLfalse%
     \unvbox\@mpfootins
     \def\baselinestretch{\m@m@footnote@spacing}%
+    \reset@font%
     \LTRfoottextfont \hsize\columnwidth \@parboxrestore
     \protected@edef\@currentlabel{%
       \csname p@mpfootnote\endcsname\@thefnmark}%
   \color@begingroup
-  \reset@font%
-    \@makefntext{%
-      \rule\z@\footnotesep\ignorespaces{\LTRfoottextfont #1}%
-      \@finalstrut\strutbox}%
+    \@normalLTRfootfmt{#1}%
   \color@endgroup}}
 \renewcommand{\@mpRTLfootnotetext}[1]{%
   \global\setbox\@mpfootins\vbox{\@RTLtrue%
     \unvbox\@mpfootins
     \def\baselinestretch{\m@m@footnote@spacing}%
+    \reset@font%
     \RTLfoottextfont \hsize\columnwidth \@parboxrestore
     \protected@edef\@currentlabel{%
       \csname p@mpfootnote\endcsname\@thefnmark}%
   \color@begingroup
-  \reset@font%
-    \@makefntext{%
-      \rule\z@\footnotesep\ignorespaces{\RTLfoottextfont #1}%
-      \@finalstrut\strutbox}%
+    \@normalRTLfootfmt{#1}%
   \color@endgroup}}
 \let\m@mold@footnotetext\@footnotetext
 \let\m@mold@LTRfootnotetext\@LTRfootnotetext
@@ -9679,7 +9700,9 @@ bidi implementation of tufte title]
   \let\@mpfootnotetext\m@mold@mpfootnotetext
   \let\@mpLTRfootnotetext\m@mold@mpLTRfootnotetext
   \let\@mpRTLfootnotetext\m@mold@mpRTLfootnotetext
-  \@bidi@after@Hy@hyperfootnotes}
+  \@bidi@after@Hy@hyperfootnotes
+  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
+}
 \@ifclassloaded{memoir}{\let\plainfootnotes\normalfootnotes}{}
 \bidi@ensure@newcommand*{\RTLcolumnfootnotes}{\@RTLcolumnfootnotestrue}
 \bidi@ensure@newcommand*{\LTRcolumnfootnotes}{\@RTLcolumnfootnotesfalse}
@@ -9742,12 +9765,27 @@ bidi implementation of tufte title]
 \newcommand*{\bidi@star@footmarkwidth}{%
   \setlength{\footmarkwidth}{0em plus.4em minus.4em}%
 }
+\bidi@normal@footmarkwidth
 \bidi@ensure@newcommand{\m@mdoextrafeet}{\extrafeetins}
 \bidi@ensure@newcommand*{\extrafeetins}{%
   \setbox\@outputbox \vbox{%
     \boxmaxdepth \@maxdepth
     \unvbox\@outputbox
-    \ifvoid\footinsv@r\else\@footstartv@r\@footgroupv@r\fi
+    \ifvoid\footinsv@r
+      \ifvoid\footinsv@l
+      \else
+        \@footstartv@l
+        \@LTRfootgroupv@l
+      \fi
+    \else
+      \@footstartv@r
+      \@footgroupv@r
+      \ifvoid\footinsv@l
+      \else
+        \@@footstart@@v@l
+        \@LTRfootgroupv@l
+      \fi
+    \fi
     \ifvoid\@bidi@copyins@
     \else
       \vskip \skip\@bidi@copyins@
@@ -9772,9 +9810,28 @@ bidi implementation of tufte title]
 \bidi@ensure@newcommand{\m@mdoextrafeetmini}{%
   \extrafeetminihook}
 \bidi@ensure@newcommand{\extrafeetendmini}{%
-  \ifvoid\@mpfootinsv@r\else
+  \ifvoid\@mpfootinsv@r
+    \ifvoid\@mpfootinsv@l
+    \else
+      \vskip\skip\@mpfootins
+      \normalcolor
+      \if@bidi@void@@mpfootins
+        \footnoterule
+      \fi
+      \mp@LTRfootgroupv@l
+    \fi
+  \else
     \vskip\skip\@mpfootins
-    \normalcolor\footnoterule\mp@footgroupv@r
+    \normalcolor
+    \if@bidi@void@@mpfootins
+      \footnoterule
+    \fi
+    \mp@footgroupv@r
+    \ifvoid\@mpfootinsv@l
+    \else
+      \vskip\skip\@mpfootins
+      \normalcolor\mp@LTRfootgroupv@l
+    \fi
   \fi
   \extrafeetendminihook}
 \bidi@ensure@newcommand{\extrafeetendminihook}{}
@@ -9782,7 +9839,10 @@ bidi implementation of tufte title]
 \def\endminipage{%
   \par
   \unskip
-  \ifvoid\@mpfootins\else
+  \ifvoid\@mpfootins
+    \global\@bidi@void@@mpfootinstrue
+  \else
+    \global\@bidi@void@@mpfootinsfalse
     \vskip\skip\@mpfootins
     \normalcolor
     \footnoterule
@@ -9806,8 +9866,11 @@ bidi implementation of tufte title]
 \count\footinsv@r=1000 % no magnifcation
 \dimen\footinsv@r=\footinsdim
 \m@make@footstart{v@r}
+\newinsert\footinsv@l
+\skip\footinsv@l\bigskipamount
 \bidi@ensure@newcommand{\@footgroupv@r}{}
 \newinsert\@mpfootinsv@r
+\newinsert\@mpfootinsv@l
 \bidi@ensure@newcommand{\mp@footgroupv@r}{}
 \newcount\m@m@k \newdimen\m@m@h
 \@ifpackageloaded{multicol}{%
@@ -9924,52 +9987,6 @@ bidi implementation of tufte title]
     \@twocolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\twocolumnfootstyle}[1]{%
-  \m@make@twocolfootnotetext{#1}%
-  \m@make@mptwocolfootnotetext{#1}%
-  \m@make@twocolfootfmt{#1}%
-  \m@make@twocol@footgroup{#1}%
-  \m@make@mptwocol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@twocolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mptwocolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@twocol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mptwocol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@twocolfootnotetext}[1]{%
-  \bidi@namelongdef{@twocolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@twocolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mptwocolfootnotetext}[1]{%
-\bidi@namelongdef{@mptwocolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@twocolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@twocolfootfmt}[1]{%
-  \@namedef{@twocolfootfmt#1}##1{%
-    \@preamtwofmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@twocol@footgroup}[1]{%
   \@namedef{@twocol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -10073,51 +10090,6 @@ bidi implementation of tufte title]
   \color@begingroup
     \@threecolRTLfootfmt{#1}%
   \color@endgroup}\m@mmf@prepare}
-\bidi@ensure@newcommand{\threecolumnfootstyle}[1]{%
-  \m@make@threecolfootnotetext{#1}%
-  \m@make@mpthreecolfootnotetext{#1}%
-  \m@make@threecolfootfmt{#1}%
-  \m@make@threecol@footgroup{#1}%
-  \m@make@mpthreecol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-    \@nameuse{@threecolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-    \@nameuse{@mpthreecolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@threecol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpthreecol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=3\footinsdim
-  \expandafter\count\csname footins#1\endcsname=333\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@threecolfootnotetext}[1]{%
-\bidi@namelongdef{@threecolfootnotetext#1}##1{%
-  \insert\@nameuse{footins#1}{%
-  \def\baselinestretch{\m@m@footnote@spacing}%
-  \reset@font\@nameuse{foottextfont#1}%
-  \@preamfntext
-  \protected@edef\@currentlabel{%
-    \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@threecolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpthreecolfootnotetext}[1]{%
-\bidi@namelongdef{@mpthreecolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@threecolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@threecolfootfmt}[1]{%
-\bidi@namelongdef{@threecolfootfmt#1}##1{%
-  \@preamthreefmt
-  {\@nameuse{footfootmark#1}\strut
-   {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@threecol@footgroup}[1]{%
 \@namedef{@threecol@footgroup#1}{{%
  \def\baselinestretch{\m@m@footnote@spacing}%
@@ -10227,52 +10199,6 @@ bidi implementation of tufte title]
     \@fourcolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\fourcolumnfootstyle}[1]{%
-  \m@make@fourcolfootnotetext{#1}%
-  \m@make@mpfourcolfootnotetext{#1}%
-  \m@make@fourcolfootfmt{#1}%
-  \m@make@fourcol@footgroup{#1}%
-  \m@make@mpfourcol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@fourcolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mpfourcolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@fourcol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpfourcol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@fourcolfootnotetext}[1]{%
-  \bidi@namelongdef{@fourcolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@fourcolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpfourcolfootnotetext}[1]{%
-\bidi@namelongdef{@mpfourcolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@fourcolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@fourcolfootfmt}[1]{%
-  \@namedef{@fourcolfootfmt#1}##1{%
-    \@preamfourfmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@fourcol@footgroup}[1]{%
   \@namedef{@fourcol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -10382,52 +10308,6 @@ bidi implementation of tufte title]
     \@fivecolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\fivecolumnfootstyle}[1]{%
-  \m@make@fivecolfootnotetext{#1}%
-  \m@make@mpfivecolfootnotetext{#1}%
-  \m@make@fivecolfootfmt{#1}%
-  \m@make@fivecol@footgroup{#1}%
-  \m@make@mpfivecol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@fivecolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mpfivecolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@fivecol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpfivecol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@fivecolfootnotetext}[1]{%
-  \bidi@namelongdef{@fivecolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@fivecolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpfivecolfootnotetext}[1]{%
-\bidi@namelongdef{@mpfivecolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@fivecolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@fivecolfootfmt}[1]{%
-  \@namedef{@fivecolfootfmt#1}##1{%
-    \@preamfivefmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@fivecol@footgroup}[1]{%
   \@namedef{@fivecol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -10537,52 +10417,6 @@ bidi implementation of tufte title]
     \@sixcolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\sixcolumnfootstyle}[1]{%
-  \m@make@sixcolfootnotetext{#1}%
-  \m@make@mpsixcolfootnotetext{#1}%
-  \m@make@sixcolfootfmt{#1}%
-  \m@make@sixcol@footgroup{#1}%
-  \m@make@mpsixcol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@sixcolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mpsixcolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@sixcol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpsixcol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@sixcolfootnotetext}[1]{%
-  \bidi@namelongdef{@sixcolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@sixcolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpsixcolfootnotetext}[1]{%
-\bidi@namelongdef{@mpsixcolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@sixcolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@sixcolfootfmt}[1]{%
-  \@namedef{@sixcolfootfmt#1}##1{%
-    \@preamsixfmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@sixcol@footgroup}[1]{%
   \@namedef{@sixcol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -10692,52 +10526,6 @@ bidi implementation of tufte title]
     \@sevencolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\sevencolumnfootstyle}[1]{%
-  \m@make@sevencolfootnotetext{#1}%
-  \m@make@mpsevencolfootnotetext{#1}%
-  \m@make@sevencolfootfmt{#1}%
-  \m@make@sevencol@footgroup{#1}%
-  \m@make@mpsevencol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@sevencolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mpsevencolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@sevencol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpsevencol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@sevencolfootnotetext}[1]{%
-  \bidi@namelongdef{@sevencolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@sevencolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpsevencolfootnotetext}[1]{%
-\bidi@namelongdef{@mpsevencolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@sevencolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@sevencolfootfmt}[1]{%
-  \@namedef{@sevencolfootfmt#1}##1{%
-    \@preamsevenfmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@sevencol@footgroup}[1]{%
   \@namedef{@sevencol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -10847,52 +10635,6 @@ bidi implementation of tufte title]
     \@eightcolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\eightcolumnfootstyle}[1]{%
-  \m@make@eightcolfootnotetext{#1}%
-  \m@make@mpeightcolfootnotetext{#1}%
-  \m@make@eightcolfootfmt{#1}%
-  \m@make@eightcol@footgroup{#1}%
-  \m@make@mpeightcol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@eightcolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mpeightcolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@eightcol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpeightcol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@eightcolfootnotetext}[1]{%
-  \bidi@namelongdef{@eightcolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@eightcolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpeightcolfootnotetext}[1]{%
-\bidi@namelongdef{@mpeightcolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@eightcolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@eightcolfootfmt}[1]{%
-  \@namedef{@eightcolfootfmt#1}##1{%
-    \@preameightfmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@eightcol@footgroup}[1]{%
   \@namedef{@eightcol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -11002,52 +10744,6 @@ bidi implementation of tufte title]
     \@ninecolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\ninecolumnfootstyle}[1]{%
-  \m@make@ninecolfootnotetext{#1}%
-  \m@make@mpninecolfootnotetext{#1}%
-  \m@make@ninecolfootfmt{#1}%
-  \m@make@ninecol@footgroup{#1}%
-  \m@make@mpninecol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@ninecolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mpninecolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@ninecol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mpninecol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@ninecolfootnotetext}[1]{%
-  \bidi@namelongdef{@ninecolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@ninecolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpninecolfootnotetext}[1]{%
-\bidi@namelongdef{@mpninecolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@ninecolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@ninecolfootfmt}[1]{%
-  \@namedef{@ninecolfootfmt#1}##1{%
-    \@preamninefmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@ninecol@footgroup}[1]{%
   \@namedef{@ninecol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -11157,52 +10853,6 @@ bidi implementation of tufte title]
     \@tencolRTLfootfmt{#1}%
   \color@endgroup}%
   \m@mmf@prepare}
-\bidi@ensure@newcommand{\tencolumnfootstyle}[1]{%
-  \m@make@tencolfootnotetext{#1}%
-  \m@make@mptencolfootnotetext{#1}%
-  \m@make@tencolfootfmt{#1}%
-  \m@make@tencol@footgroup{#1}%
-  \m@make@mptencol@footgroup{#1}%
-  \m@make@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-     \@nameuse{@tencolfootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-     \@nameuse{@mptencolfootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@tencol@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mptencol@footgroup#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=2\footinsdim
-  \expandafter\count\csname footins#1\endcsname=500\relax
-  \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@tencolfootnotetext}[1]{%
-  \bidi@namelongdef{@tencolfootnotetext#1}##1{%
-    \insert\@nameuse{footins#1}{%
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \@preamfntext
-    \protected@edef\@currentlabel{%
-      \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-    \color@begingroup
-      \@nameuse{@tencolfootfmt#1}{##1}%
-    \color@endgroup}%
-    \m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mptencolfootnotetext}[1]{%
-\bidi@namelongdef{@mptencolfootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-  \color@begingroup
-    \@nameuse{@tencolfootfmt#1}{##1}%
-  \color@endgroup}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@tencolfootfmt}[1]{%
-  \@namedef{@tencolfootfmt#1}##1{%
-    \@preamtenfmt
-    {\@nameuse{footfootmark#1}\strut
-     {\@nameuse{foottextfont#1}##1}\strut\par}\allowbreak}}
 \bidi@ensure@newcommand{\m@make@tencol@footgroup}[1]{%
   \@namedef{@tencol@footgroup#1}{{%
    \def\baselinestretch{\m@m@footnote@spacing}%
@@ -11233,7 +10883,6 @@ bidi implementation of tufte title]
 \m@minterparanoteglue{1em plus.4em minus.4em}
 \@ifpackageloaded{multicol}{%
 \bidi@ensure@newcommand*{\m@mmakehboxofhboxes}{%
- \if@parafootRTL\@RTLtrue\else\@RTLfalse\fi%
  \hsize\textwidth%
  \setbox0=\hbox{}%
   \loop
@@ -11244,7 +10893,6 @@ bidi implementation of tufte title]
   \repeat}
 }{%
 \bidi@ensure@newcommand*{\m@mmakehboxofhboxes}{%
- \if@parafootRTL\@RTLtrue\else\@RTLfalse\fi%
  \setbox0=\hbox{}%
   \loop
     \unpenalty
@@ -11277,12 +10925,84 @@ bidi implementation of tufte title]
   \m@make@para@footstart{v@r}%
   \let\@footgroupv@r\@para@footgroupv@r
   \let\@footstartv@r\@para@footstartv@r
+  \dimen\footinsv@l=\footinsdim
+  \count\footinsv@l=1000\relax
+  \bidi@make@para@LTRfootgroup{v@l}%
+  \m@make@para@footstart{v@l}%
+  \bidi@make@para@footstart@@{v@l}%
+  \let\@LTRfootgroupv@l\@para@LTRfootgroupv@l
+  \let\@footstartv@l\@para@footstartv@l
+  \let\@@footstart@@v@l\@@para@footstart@@v@l
   \let\@mpfootnotetext\@mpparafootnotetext
   \let\@mpLTRfootnotetext\@mpparaLTRfootnotetext
   \let\@mpRTLfootnotetext\@mpparaRTLfootnotetext
   \@bidi@after@Hy@hyperfootnotes
   \m@make@mppara@footgroup{v@r}%
+  \bidi@make@mppara@LTRfootgroup{v@l}%
+  \let\mp@footgroupv@r\@mppara@footgroupv@r
+  \let\mp@LTRfootgroupv@l\@mppara@LTRfootgroupv@l
+  \begingroup
+  \def\baselinestretch{\m@m@footnote@spacing}%
+   \foottextfont
+   \@tempdima\footnotesep
+   \advance\@tempdima -\ht\strutbox
+   \ifdim\@tempdima<\z@ \@tempdima\z@ \fi
+   \advance\@tempdima.5\normalbaselineskip
+   \bidi@xparaskip
+   \xdef\bidi@paraskip{\the\@tempdima\relax}%
+   \ifdim\skip\footinsv@r>\bigskipamount
+   \else
+     \global\advance\skip\footinsv@r\bidi@paraskip
+   \fi
+   \ifdim\skip\footinsv@l>\bigskipamount
+   \else
+     \global\advance\skip\footinsv@l\bidi@paraskip
+   \fi
+   \@tempdima\normalbaselineskip
+   \multiply \@tempdima \@cclvi
+   \@tempdimb \columnwidth
+   \divide \@tempdimb \@cclvi
+   \divide \@tempdima \@tempdimb
+   \xdef\footfudgefactor{\strip@pt\@tempdima}%
+   \endgroup
+   \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
+}
+\newcommand{\normalRTLparaLTRfootnotes}{%
+  \@namedef{foottextfontv@r}{\foottextfont}%  
+  \@bidi@before@Hy@hyperfootnotes
+  \if@RTL@footnote
+    \let\@footnotetext\m@mold@footnotetext
+  \else
+    \let\@footnotetext\@parafootnotetext
+  \fi
+  \let\@LTRfootnotetext\@paraLTRfootnotetext
+  \let\@RTLfootnotetext\m@mold@RTLfootnotetext
+  \dimen\footinsv@r=\footinsdim
+  \count\footinsv@r=1000\relax
+  \m@make@para@footgroup{v@r}%
+  \m@make@para@footstart{v@r}%
+  \let\@footgroupv@r\@para@footgroupv@r
+  \let\@footstartv@r\@para@footstartv@r
+  \dimen\footinsv@l=\footinsdim
+  \count\footinsv@l=1000\relax
+  \bidi@make@para@LTRfootgroup{v@l}%
+  \m@make@para@footstart{v@l}%
+  \bidi@make@para@footstart@@{v@l}%
+  \let\@LTRfootgroupv@l\@para@LTRfootgroupv@l
+  \let\@footstartv@l\@para@footstartv@l
+  \let\@@footstart@@v@l\@@para@footstart@@v@l
+  \if@RTL@footnote
+    \let\@mpfootnotetext\m@mold@mpfootnotetext
+  \else
+    \let\@mpfootnotetext\@mpparafootnotetext
+  \fi
+  \let\@mpLTRfootnotetext\@mpparaLTRfootnotetext
+  \let\@mpRTLfootnotetext\m@mold@mpRTLfootnotetext
+  \@bidi@after@Hy@hyperfootnotes
+  \m@make@mppara@footgroup{v@r}%
+  \bidi@make@mppara@LTRfootgroup{v@l}%
   \let\mp@footgroupv@r\@mppara@footgroupv@r
+  \let\mp@LTRfootgroupv@l\@mppara@LTRfootgroupv@l
   \begingroup
   \def\baselinestretch{\m@m@footnote@spacing}%
    \foottextfont
@@ -11296,6 +11016,10 @@ bidi implementation of tufte title]
    \else
      \global\advance\skip\footinsv@r\bidi@paraskip
    \fi
+   \ifdim\skip\footinsv@l>\bigskipamount
+   \else
+     \global\advance\skip\footinsv@l\bidi@paraskip
+   \fi
    \@tempdima\normalbaselineskip
    \multiply \@tempdima \@cclvi
    \@tempdimb \columnwidth
@@ -11307,7 +11031,13 @@ bidi implementation of tufte title]
 }
 \let\bidi@xparaskip\relax
 \@onlypreamble\AddExtraParaSkip
-\bidi@ensure@newcommand{\@parafootnotetext}[1]{\insert\footinsv@r{%
+\bidi@ensure@newcommand{\@parafootnotetext}[1]{\insert
+  \if@RTL@footnote
+    \footinsv@r
+  \else
+    \footinsv@l
+  \fi
+  {%
   \let\bidi@RTL@everypar\@empty%
   \def\baselinestretch{\m@m@footnote@spacing}%
   \reset@font\foottextfont
@@ -11316,10 +11046,10 @@ bidi implementation of tufte title]
     \csname p@footnote\endcsname\@thefnmark}%
   \setbox0=\vbox{\hsize=\maxdimen
     \color@begingroup
-      \noindent \@parafootfmt{\if@RTL@footnote\beginR\else\beginL\fi#1\if@RTL@footnote\endR\else\endL\fi}%
+      \noindent \@parafootfmt{#1}%
     \color@endgroup}%
   \m@mungebox}\m@mmf@prepare}
-\bidi@ensure@newcommand{\@paraLTRfootnotetext}[1]{\insert\footinsv@r{%
+\bidi@ensure@newcommand{\@paraLTRfootnotetext}[1]{\insert\footinsv@l{%
  \let\bidi@RTL@everypar\@empty%
  \def\baselinestretch{\m@m@footnote@spacing}%
   \reset@font\LTRfoottextfont
@@ -11328,7 +11058,7 @@ bidi implementation of tufte title]
     \csname p@footnote\endcsname\@thefnmark}%
   \setbox0=\vbox{\hsize=\maxdimen
     \color@begingroup
-      \noindent \@paraLTRfootfmt{\beginL#1\endL}%
+      \noindent \@paraLTRfootfmt{#1}%
     \color@endgroup}%
   \m@mungebox}\m@mmf@prepare}
 \bidi@ensure@newcommand{\@paraRTLfootnotetext}[1]{\insert\footinsv@r{%
@@ -11340,7 +11070,7 @@ bidi implementation of tufte title]
     \csname p@footnote\endcsname\@thefnmark}%
   \setbox0=\vbox{\hsize=\maxdimen
     \color@begingroup
-      \noindent \@paraRTLfootfmt{\beginR#1\endR}%
+      \noindent \@paraRTLfootfmt{#1}%
     \color@endgroup}%
   \m@mungebox}\m@mmf@prepare}
 \bidi@ensure@newcommand{\@parafootfmt}[1]{%
@@ -11356,31 +11086,42 @@ bidi implementation of tufte title]
   \parfillskip=0pt \@plus 1fil
   {\RTLfootfootmark\strut {\RTLfoottextfont #1}\penalty-10}}
 \bidi@ensure@newcommand{\@mpparafootnotetext}[1]{%
-  \global\setbox\@mpfootinsv@r\vbox{%
+  \global\setbox
+  \if@RTL@footnote
+    \@mpfootinsv@r
+  \else
+    \@mpfootinsv@l
+  \fi
+  \vbox{%
     \let\bidi@RTL@everypar\@empty%
     \def\baselinestretch{\m@m@footnote@spacing}%
-    \unvbox\@mpfootinsv@r
+    \unvbox
+    \if@RTL@footnote
+      \@mpfootinsv@r
+    \else
+      \@mpfootinsv@l
+    \fi
     \reset@font\foottextfont
     \hsize\columnwidth \@parboxrestore
     \protected@edef\@currentlabel{%
       \csname p@mpfootnote\endcsname\@thefnmark}%
     \setbox0=\vbox{\hsize=\maxdimen
       \color@begingroup
-      \noindent \@parafootfmt{\if@RTL@footnote\beginR\else\beginL\fi#1\if@RTL@footnote\endR\else\endL\fi}%
+      \noindent \@parafootfmt{#1}%
       \color@endgroup}%
   \m@mungebox}\m@mmf@prepare}
 \bidi@ensure@newcommand{\@mpparaLTRfootnotetext}[1]{%
-  \global\setbox\@mpfootinsv@r\vbox{%
+  \global\setbox\@mpfootinsv@l\vbox{%
    \let\bidi@RTL@everypar\@empty%
    \def\baselinestretch{\m@m@footnote@spacing}%
-    \unvbox\@mpfootinsv@r
+    \unvbox\@mpfootinsv@l
     \reset@font\LTRfoottextfont
     \hsize\columnwidth \@parboxrestore
     \protected@edef\@currentlabel{%
       \csname p@mpfootnote\endcsname\@thefnmark}%
     \setbox0=\vbox{\hsize=\maxdimen
       \color@begingroup
-      \noindent \@paraLTRfootfmt{\beginL#1\endL}%
+      \noindent \@paraLTRfootfmt{#1}%
       \color@endgroup}%
   \m@mungebox}\m@mmf@prepare}
 \bidi@ensure@newcommand{\@mpparaRTLfootnotetext}[1]{%
@@ -11394,83 +11135,23 @@ bidi implementation of tufte title]
       \csname p@mpfootnote\endcsname\@thefnmark}%
     \setbox0=\vbox{\hsize=\maxdimen
       \color@begingroup
-      \noindent \@paraRTLfootfmt{\beginR#1\endR}%
+      \noindent \@paraRTLfootfmt{#1}%
       \color@endgroup}%
   \m@mungebox}\m@mmf@prepare}
-\bidi@ensure@newcommand{\paragraphfootstyle}[1]{%
-  \m@make@parafootnotetext{#1}%
-  \m@make@mpparafootnotetext{#1}%
-  \m@make@parafootfmt{#1}%
-  \m@make@para@footgroup{#1}%
-  \m@make@mppara@footgroup{#1}%
-  \m@make@para@footstart{#1}%
-  \bidi@namelongdef{@footnotetext#1}##1{%
-    \@nameuse{@parafootnotetext#1}{##1}}%
-  \bidi@namelongdef{@mpfootnotetext#1}##1{%
-    \@nameuse{@mpparafootnotetext#1}{##1}}%
-  \@namedef{@footgroup#1}{\@nameuse{@para@footgroup#1}}%
-  \@namedef{mp@footgroup#1}{\@nameuse{@mppara@footgroup#1}}%
-  \@namedef{@footstart#1}{\@nameuse{@para@footstart#1}}%
-  \expandafter\dimen\csname footins#1\endcsname=\footinsdim
-  \expandafter\count\csname footins#1\endcsname=1000\relax
-  \begingroup
-  \def\baselinestretch{\m@m@footnote@spacing}%
-   \@nameuse{foottextfont#1}%
-   \@tempdima\footnotesep
-   \advance\@tempdima -\ht\strutbox
-   \ifdim\@tempdima<\z@ \@tempdima\z@ \fi
-   \advance\@tempdima.5\normalbaselineskip
-   \bidi@xparaskip
-   \xdef\bidi@paraskip{\the\@tempdima\relax}%
-   \ifdim\skip\@nameuse{footins#1}>\bigskipamount
-   \else
-     \global\advance\skip\@nameuse{footins#1}\bidi@paraskip
-   \fi
-   \@tempdima\normalbaselineskip
-   \multiply \@tempdima \@cclvi
-   \@tempdimb \columnwidth
-   \divide \@tempdimb \@cclvi
-   \divide \@tempdima \@tempdimb
-   \xdef\footfudgefactor{\strip@pt\@tempdima}%
-   \endgroup
-   \@ifstar\bidi@star@footmarkwidth\bidi@normal@footmarkwidth
-}
-\bidi@ensure@newcommand{\m@make@parafootnotetext}[1]{%
-\bidi@namelongdef{@parafootnotetext#1}##1{%
-  \insert\@nameuse{footins#1}{
-  \def\baselinestretch{\m@m@footnote@spacing}%
-  \reset@font\@nameuse{foottextfont#1}%
-  \@preamfntext
-  \protected@edef\@currentlabel{%
-    \csname p@footnote#1\endcsname \@nameuse{@thefnmark#1}}%
-  \setbox0=\vbox{\hsize=\maxdimen
-    \color@begingroup
-      \noindent \@nameuse{@parafootfmt#1}{##1}%
-    \color@endgroup}%
-  \m@mungebox}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@mpparafootnotetext}[1]{%
-\bidi@namelongdef{@mpparafootnotetext#1}##1{%
-  \global\setbox\@nameuse{@mpfootins#1}\vbox{%
-    \unvbox\@nameuse{@mpfootins#1}
-    \def\baselinestretch{\m@m@footnote@spacing}%
-    \reset@font\@nameuse{foottextfont#1}%
-    \hsize\columnwidth \@parboxrestore
-    \protected@edef\@currentlabel{%
-      \csname p@mpfootnote#1\endcsname\@nameuse{@thefnmark#1}}%
-    \setbox0=\vbox{\hsize=\maxdimen
-      \color@begingroup
-        \noindent \@nameuse{@parafootfmt#1}{##1}%
-      \color@endgroup}%
-    \m@mungebox}\m@mmf@prepare}}
-\bidi@ensure@newcommand{\m@make@parafootfmt}[1]{%
-\bidi@namelongdef{@parafootfmt#1}##1{%
-  \parindent=\z@
-  \parfillskip=0pt \@plus 1fil
-  {\@nameuse{footfootmark#1}\strut
-   {\@nameuse{foottextfont#1}##1}\penalty-10}}}
 \bidi@ensure@newcommand{\m@make@para@footgroup}[1]{%
 \@namedef{@para@footgroup#1}{%
   \unvbox\@nameuse{footins#1}
+  \@RTLtrue
+  \m@mmakehboxofhboxes
+  \setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
+  \@parboxrestore%
+  \def\baselinestretch{\m@m@footnote@spacing}%
+  \@nameuse{foottextfont#1}%
+  \noindent\unhbox0\par}}
+\bidi@ensure@newcommand{\bidi@make@para@LTRfootgroup}[1]{%
+\@namedef{@para@LTRfootgroup#1}{%
+  \unvbox\@nameuse{footins#1}
+  \@RTLfalse
   \m@mmakehboxofhboxes
   \setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
   \@parboxrestore%
@@ -11480,6 +11161,16 @@ bidi implementation of tufte title]
 \bidi@ensure@newcommand{\m@make@mppara@footgroup}[1]{%
 \@namedef{@mppara@footgroup#1}{%
   \unvbox\@nameuse{@mpfootins#1}
+  \@RTLtrue
+  \m@mmakehboxofhboxes
+  \setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
+  \def\baselinestretch{\m@m@footnote@spacing}%
+  \@nameuse{foottextfont#1}%
+  \noindent\unhbox0\par}}
+\bidi@ensure@newcommand{\bidi@make@mppara@LTRfootgroup}[1]{%
+\@namedef{@mppara@LTRfootgroup#1}{%
+  \unvbox\@nameuse{@mpfootins#1}
+  \@RTLfalse
   \m@mmakehboxofhboxes
   \setbox0=\hbox{\unhbox0 \m@mremovehboxes}%
   \def\baselinestretch{\m@m@footnote@spacing}%
@@ -11492,7 +11183,16 @@ bidi implementation of tufte title]
   \rightskip=\z@
   \parindent=\z@
   \vskip\skip\footins
-  \footnoterule}}
+  \if@bidi@void@footins
+    \footnoterule
+  \fi}}
+\bidi@ensure@newcommand{\bidi@make@para@footstart@@}[1]{%
+\@namedef{@@para@footstart@@#1}{%
+  \bidi@mopfn@bottom
+  \leftskip=\z@
+  \rightskip=\z@
+  \parindent=\z@
+  \vskip\skip\footins}}
 \bidi@ensure@newcommand*{\m@m@makecolfloats}{%
   \xdef\@freelist{\@freelist\@midlist}%
   \global\let\@midlist\@empty
@@ -11521,32 +11221,8 @@ bidi implementation of tufte title]
     \footnoterule
     \unvbox \footins
   \color@endgroup
-  \ifvoid\footinsv@r
-    \ifvoid\@bidi@copyins@
-    \else
-      \vskip \skip\@bidi@copyins@
-      \color@begingroup
-        \normalcolor
-        \unvbox \@bidi@copyins@
-      \color@endgroup
-    \fi
-  \fi
-  }}
-\newcommand*{\bidi@mopcopyins}{\setbox\@outputbox \vbox{%
-  \boxmaxdepth\@maxdepth
-  \@tempdima\dp\@cclv
-  \unvbox\@cclv
-  \vskip-\@tempdima
-  \bidi@mopfn@bottom
-  \ifvoid\@bidi@copyins@
-  \else
-    \vskip \skip\@bidi@copyins@
-    \color@begingroup
-      \normalcolor
-      \unvbox \@bidi@copyins@
-    \color@endgroup
-  \fi
-  }}
+  }%
+}
 \newcommand*{\bidi@mopfootnotebf}{%
   \setbox\@outputbox \vbox{%
   \boxmaxdepth\@maxdepth
@@ -11558,44 +11234,15 @@ bidi implementation of tufte title]
     \footnoterule
     \unvbox \footins
   \color@endgroup
-  \ifvoid\footinsv@r
-    \ifvoid\@bidi@copyins@
-    \else
-      \vskip \skip\@bidi@copyins@
-      \color@begingroup
-        \normalcolor
-        \unvbox \@bidi@copyins@
-      \color@endgroup
-    \fi 
-  \fi
-  }}
-\newcommand*{\bidi@mopcopyinsbf}{%
-  \setbox\@outputbox \vbox{%
-  \boxmaxdepth\@maxdepth
-  \unvbox\@outputbox
-  \bidi@mopfn@bottom
-  \ifvoid\@bidi@copyins@
-  \else
-    \vskip \skip\@bidi@copyins@
-    \color@begingroup
-      \normalcolor
-      \unvbox \@bidi@copyins@
-    \color@endgroup
-  \fi 
-  }}
+  }%
+}
 \gdef\mem@makecol{%
   \m@m@makecolintro
   \ifvoid\footins
-    \ifvoid\footinsv@r
-      \ifvoid\@bidi@copyins@
-        \setbox\@outputbox \box\@cclv
-      \else
-        \bidi@mopcopyins
-      \fi
-    \else
-      \setbox\@outputbox \box\@cclv
-    \fi
+    \global\@bidi@void@footinstrue
+    \setbox\@outputbox \box\@cclv
   \else
+    \global\@bidi@void@footinsfalse
     \m@mopfootnote
   \fi
   \m@mdoextrafeet
@@ -11607,13 +11254,9 @@ bidi implementation of tufte title]
   \setbox\@outputbox \box\@cclv
   \m@m@makecolfloats
   \ifvoid\footins
-    \ifvoid\footinsv@r
-      \ifvoid\@bidi@copyins@
-      \else
-        \bidi@mopcopyinsbf
-      \fi
-    \fi
+    \global\@bidi@void@footinstrue
   \else
+    \global\@bidi@void@footinsfalse
     \bidi@mopfootnotebf
   \fi
   \m@mdoextrafeet
@@ -16048,7 +15691,7 @@ bidi implementation of tufte title]
 %\fi
 % \section{File \texttt{multicol-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{multicol-xetex-bidi.def}[2018/09/26 v1.0 bidi adaptations for multicol package for XeTeX engine]
+\ProvidesFile{multicol-xetex-bidi.def}[2018/10/07 v1.1 bidi adaptations for multicol package for XeTeX engine]
 \def\page@sofar{%
    \process@cols\mult@rightbox
        {\ifvoid\count@
@@ -16133,7 +15776,7 @@ bidi implementation of tufte title]
 \newcommand\bidi@multicol@align@columns
     {\if@RTLmain\RTL@column@boxes\else\LTR@column@boxes\fi}
 \bidi@AtEndPreamble{%
-  \if@bidi@csdef{footinsv@r}{%
+  \if@bidi@csdef{footinsv@l}{%
     \def\footnoterule{\kern-3\p@
       \hrule \@width \textwidth \kern 2.6\p@}%
   }{}%
@@ -16189,28 +15832,49 @@ bidi implementation of tufte title]
    \advance\dimen@-\ht\@bidi@copyins@
 }
 \bidi@AtEndPreamble{%
-  \if@bidi@csdef{footinsv@r}{%
+  \if@bidi@csdef{footinsv@l}{%
     \def\bidi@leave@mult@footins@vr{%
        \advance\dimen@-\skip\footinsv@r
        \advance\dimen@-\ht\footinsv@r
      }%
+    \def\bidi@leave@mult@footins@vl{%
+       \advance\dimen@-\skip\footinsv@l
+       \advance\dimen@-\ht\footinsv@l
+     }%
     \def\bidi@init@mult@footinsv@r{%
       \multiply\count\footinsv@r\col@number
       \multiply\skip \footinsv@r\col@number
     }%
+    \def\bidi@init@mult@footinsv@l{%
+      \multiply\count\footinsv@l\col@number
+      \multiply\skip \footinsv@l\col@number
+    }%
     \def\bidi@reinsert@footnotesv@r{\ifvoid\footinsv@r\else
              \insert\footinsv@r{}\fi}%
+    \def\bidi@reinsert@footnotesv@l{\ifvoid\footinsv@l\else
+             \insert\footinsv@l{}\fi}%
     \bidi@patchcmd{\prepare@multicols}{%
       \reinsert@footnotes
     }{%
       \reinsert@footnotes
       \bidi@init@mult@footinsv@r
       \bidi@reinsert@footnotesv@r
+      \bidi@init@mult@footinsv@l
+      \bidi@reinsert@footnotesv@l
     }{}{}%
     \bidi@patchcmd{\multi@column@out}{%
       \ifnum \c@tracingmulticols>\thr@@
     }{%
-       \ifvoid\footinsv@r\else
+       \ifvoid\footinsv@r
+         \ifvoid\footinsv@l
+         \else
+           \PackageWarning{multicol}%
+            {I moved some lines to
+             the next page.\MessageBreak
+             Footnotes on page
+             \thepage\space might be wrong}%    
+         \fi
+       \else
          \PackageWarning{multicol}%
           {I moved some lines to
            the next page.\MessageBreak
@@ -16224,28 +15888,35 @@ bidi implementation of tufte title]
 }{%
   \reinsert@footnotes
   \bidi@reinsert@footnotesv@r
+  \bidi@reinsert@footnotesv@l
 }{}{}%
 \bidi@patchcmd{\speci@ls}{%
   \reinsert@footnotes
 }{%
   \reinsert@footnotes
   \bidi@reinsert@footnotesv@r
+  \bidi@reinsert@footnotesv@l
 }{}{}%
 \bidi@patchcmd{\speci@ls}{%
   \reinsert@footnotes
 }{%
   \reinsert@footnotes
   \bidi@reinsert@footnotesv@r
+  \bidi@reinsert@footnotesv@l
 }{}{}%
   }{}%
   \bidi@patchcmd{\multi@column@out}{%
      \let\ifshr@kingsaved\ifshr@king
   }{%
-    \if@bidi@csdef{footinsv@r}{%
+    \if@bidi@csdef{footinsv@l}{%
       \divide\skip\footinsv@r\col@number
        \ifvoid\footinsv@r \else
           \bidi@leave@mult@footins@vr
        \fi
+      \divide\skip\footinsv@l\col@number
+       \ifvoid\footinsv@l \else
+          \bidi@leave@mult@footins@vl
+       \fi
      }{}%
      \ifvoid\@bidi@copyins@ \else
         \bidi@leave@mult@copyins
-- 
cgit v1.2.3

