summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-02-16 21:41:05 +0000
committerKarl Berry <karl@freefriends.org>2015-02-16 21:41:05 +0000
commit6b7b72d8eb76ae970a44028cf4b89cb420824061 (patch)
tree3c9b50cfc3a862032b34e3c24afc7277765830d6 /Master/texmf-dist/source/xelatex
parent68695b0b7015bb233b4f5697ebdb9def46b9cb4a (diff)
bidi (16feb15)
git-svn-id: svn://tug.org/texlive/trunk@36297 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/xelatex')
-rw-r--r--Master/texmf-dist/source/xelatex/bidi/bidi.dtx564
1 files changed, 543 insertions, 21 deletions
diff --git a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
index c1147fa74e5..4cc47cff72a 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
-v16.6
+v16.7
This package provides a convenient interface for typesetting
bidirectional texts in Plain TeX and LaTeX, using XeTeX engine.
@@ -25,7 +25,7 @@ a minimal working example showing the issue, and always choose the appropriate
label for your query (i.e. if you are reporting any bugs, choose `Bug' label).
-Current version release date: 2015/02/01
+Current version release date: 2015/02/16
___________________
Vafa Khalighi
@@ -318,7 +318,7 @@ by Vafa Khalighi.
%\changes{v13.9}{2013/09/23}{Added implementaion of the package.}
% \title{\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}\\
%\LARGE Bidirectional typesetting in plain \TeX{} and \LaTeX, using \XeTeX{} engine\\[5pt]
-%\large Documentation for \textcolor{blue!65!black}{version 16.6}}
+%\large Documentation for \textcolor{blue!65!black}{version 16.7}}
% \author{Vafa Khalighi\\
% \url{persian-tex@tug.org}}
%\setcounter{page}{0}
@@ -329,7 +329,7 @@ by Vafa Khalighi.
%\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}
%
%\Large
-%Documentation for \textcolor{blue!65!black}{version 16.6}}
+%Documentation for \textcolor{blue!65!black}{version 16.7}}
%
%\vskip 0pt plus 3fill
%\textit{\large to my Master, \textbf{Ferdowsi The Great}}
@@ -380,7 +380,7 @@ by Vafa Khalighi.
%*
%* Copyright (c) 2009--2015 Vafa Khalighi
%*
-%* 2015/02/01, v16.6
+%* 2015/02/16, v16.7
%*
%* License: LaTeX Project Public License, version
%* 1.3c or higher (your choice)
@@ -1137,7 +1137,7 @@ by Vafa Khalighi.
%\iffalse
%<*table>
%\fi
-%% \CheckSum{43266}
+%% \CheckSum{44128}
%% \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
@@ -2717,8 +2717,8 @@ by Vafa Khalighi.
% \subsection{\textsf{bidi.sty}}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\def\bididate{2015/02/01}
-\def\bidiversion{v16.6}
+\def\bididate{2015/02/16}
+\def\bidiversion{v16.7}
\ProvidesPackage{bidi}[\bididate\space \bidiversion\space
Bidirectional typesetting in plain TeX and LaTeX]
\edef\@bidi@info{****************************************************^^J%
@@ -2840,7 +2840,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
%\fi
% \subsection{\textsf{bidi.tex}}
% \begin{macrocode}
-\def\bididate{2015/02/01}
+\def\bididate{2015/02/16}
\def\bidiversion{v0.2}
\catcode`@=11
\let \protect \relax
@@ -3636,7 +3636,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
% \subsection{\textsf{biditools.sty}}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{biditools}[2015/02/01 v0.3 Programming tools for bidi package]
+\ProvidesPackage{biditools}[2015/02/16 v0.4 Programming tools for bidi package]
\providecommand{\@bidi@saveprimitive}[2]{\begingroup\escapechar`\\\relax
\edef\@tempa{\string#1}\edef\@tempb{\meaning#1}%
\ifx\@tempa\@tempb \global\let#2#1%
@@ -4181,6 +4181,528 @@ Bidirectional typesetting in plain TeX and LaTeX]
{\bidi@warning{%
Patching '\string\end' failed!\MessageBreak
'\string\bidi@AfterEndEnvironment' will not work\@gobble}}
+
+\CheckCommand{\InputIfFileExists}[2]{%
+ \IfFileExists{#1}%
+ {#2\@addtofilelist{#1}\@@input \@filef@und}}
+
+\renewcommand{\InputIfFileExists}[2]{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@bidi@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \bidi@replacefile@msg{\csname #1-@bidi@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@bidi@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \bidi@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \@@input \@filef@und
+ \bidi@load@hook{after}{#1}%
+ }}%
+}
+
+\newcommand*{\bidi@@loadwithoptions}{}
+\newcommand*{\bidi@loadwithoptions}{}
+\let\bidi@loadwithoptions\@loadwithoptions
+
+\renewcommand*{\@loadwithoptions}[3]{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #3.#1-@bidi@aliasname\endcsname\relax
+ \def\bidi@@loadwithoptions{\bidi@loadwithoptions{#1}{#2}{#3}}%
+ \else
+ \bidi@replacefile@msg{\csname #3.#1-@bidi@aliasname\endcsname.#1}{#3.#1}%
+ \def\bidi@@loadwithoptions{%
+ \@loadwithoptions{#1}{#2}{\csname #3.#1-@bidi@aliasname\endcsname}%
+ }%
+ \fi
+ \bidi@@loadwithoptions
+}
+
+\newcommand*{\bidi@onefilewithoptions}{}
+\let\bidi@onefilewithoptions\@onefilewithoptions
+\def\@onefilewithoptions#1[#2][#3]#4{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1.#4-@bidi@aliasname\endcsname\relax
+ \def\bidi@@onefilewithoptions{\bidi@onefilewithoptions{#1}}%
+ \else
+ \bidi@replacefile@msg{\csname #1.#4-@bidi@aliasname\endcsname.#4}{#1.#4}%
+ \edef\bidi@@onefilewithoptions{%
+ \noexpand\@onefilewithoptions{\csname #1.#4-@bidi@aliasname\endcsname}}%
+ \fi
+ \bidi@@onefilewithoptions[{#2}][{#3}]{#4}%
+ \bidi@load@hook{lateafter}{#1.#4}%
+}
+
+\newcommand*{\bidi@ReplaceInput}[2]{%
+ \expandafter\edef\csname #1-@bidi@alias\endcsname{#2}%
+}
+
+\newcommand*{\bidi@UnReplaceInput}[1]{%
+ \ifcsname #1-@bidi@alias\endcsname
+ \expandafter\let\csname #1-@bidi@alias\endcsname\relax
+ \fi
+}
+
+\newcommand*{\@bidi@replacefilewithext}[3]{%
+ \expandafter\edef\csname #1.#3-@bidi@aliasname\endcsname{#2}%
+ }
+\newcommand*{\bidi@ReplacePackage}[2]{%
+ \@bidi@replacefilewithext{#1}{#2}\@pkgextension
+}
+\newcommand*{\bidi@ReplaceClass}[2]{%
+ \@bidi@replacefilewithext{#1}{#2}\@clsextension
+}
+\newcommand*{\@bidi@unreplacefilewithext}[2]{%
+ \ifcsname #1.#2-@bidi@aliasname\endcsname
+ \expandafter\let\csname #1.#2-@bidi@aliasname\endcsname\relax
+ \fi
+}
+\newcommand*{\bidi@UnReplacePackage}[1]{%
+ \@bidi@unreplacefilewithext{#1}\@pkgextension
+}
+\newcommand*{\bidi@UnReplaceClass}[1]{%
+ \@bidi@unreplacefilewithext{#1}\@clsextension
+}
+\newcommand*{\bidi@replacefile@msg}[2]{%
+ \PackageInfo{biditools}{inputing `#1' instead of `#2'}%
+}
+
+\newcommand*{\bidi@load@hook}[2]{%
+ \@ifundefined{#2-@#1}{}{%
+ \@nameuse{#2-@#1}%
+ \expandafter\let\csname #2-@#1\endcsname=\relax}}
+\newcommand*{\bidi@set@load@hook}[2]{%
+ \@ifundefined{#2-@#1}{\@namedef{#2-@#1}{}}{}%
+ \expandafter\g@addto@macro\csname #2-@#1\endcsname}
+\newcommand*{\bidi@BeforeFile}{\bidi@set@load@hook{before}}
+\newcommand*{\bidi@AfterFile}{\bidi@set@load@hook{after}}
+\newcommand*{\bidi@BeforeClass}[1]{%
+ \bidi@set@load@hook{before}{#1.\@clsextension}}
+\newcommand*{\bidi@AfterClass}{%
+ \@ifstar {\@s@bidi@AfterClass}{%
+ \@ifnextchar +\@@bidi@AfterClass{%
+ \@ifnextchar !\@@@bidi@AfterClass\@bidi@AfterClass
+ }%
+ }%
+}
+
+\newcommand*{\@@@bidi@AfterClass}[2]{%
+ \begingroup\ifx\csname #2.\@clsextension-h@@k\endcsname\relax
+ \aftergroup\@s@bidi@AfterClass
+ \else
+ \aftergroup\bidi@AfterAtEndOfClass
+ \fi
+ \endgroup{#2}%
+}
+
+\newcommand*{\bidi@AfterAtEndOfClass}[1]{%
+ \bidi@set@load@hook{lateafter}{#1.\@clsextension}}
+\newcommand*{\@@bidi@AfterClass}[2]{%
+ \begingroup
+ \expandafter\ifx\csname #2.\@clsextension-h@@k\endcsname\relax
+ \aftergroup\@s@bidi@AfterClass
+ \else
+ \aftergroup\@bidi@AfterClass
+ \fi
+ \endgroup{#2}%
+}
+
+\newcommand*{\@bidi@AfterClass}[1]{%
+ \bidi@set@load@hook{after}{#1.\@clsextension}}
+\newcommand*{\@s@bidi@AfterClass}[1]{%
+ \begingroup
+ \@ifclassloaded{#1}{%
+ \aftergroup\@secondoftwo
+ }{%
+ \aftergroup\@bidi@AfterClass
+ }%
+ \endgroup
+ {#1}%
+}
+
+
+\newcommand*{\bidi@BeforePackage}[1]{%
+ \bidi@set@load@hook{before}{#1.\@pkgextension}}
+\newcommand*{\bidi@AfterPackage}{%
+ \@ifstar {\@s@bidi@AfterPackage}{%
+ \@ifnextchar +\@@bidi@AfterPackage{%
+ \@ifnextchar !\@@@bidi@AfterPackage\@bidi@AfterPackage
+ }%
+ }%
+}
+\newcommand*{\@@@bidi@AfterPackage}[2]{%
+ \begingroup\ifx\csname #2.\@pkgextension-h@@k\endcsname\relax
+ \aftergroup\@s@bidi@AfterPackage
+ \else
+ \aftergroup\bidi@AfterAtEndOfPackage
+ \fi
+ \endgroup{#2}%
+}
+\newcommand*{\bidi@AfterAtEndOfPackage}[1]{%
+ \bidi@set@load@hook{lateafter}{#1.\@pkgextension}}
+\newcommand*{\@@bidi@AfterPackage}[2]{%
+ \begingroup
+ \expandafter\ifx\csname #2.\@pkgextension-h@@k\endcsname\relax
+ \aftergroup\@s@bidi@AfterPackage
+ \else
+ \aftergroup\@bidi@AfterPackage
+ \fi
+ \endgroup{#2}%
+}
+\newcommand*{\@bidi@AfterPackage}[1]{%
+ \bidi@set@load@hook{after}{#1.\@pkgextension}}
+\newcommand*{\@s@bidi@AfterPackage}[1]{%
+ \begingroup
+ \@ifpackageloaded{#1}{%
+ \aftergroup\@secondoftwo
+ }{%
+ \aftergroup\@bidi@AfterPackage
+ }%
+ \endgroup
+ {#1}%
+}
+
+\newcommand*{\bidi@excludedpackages}{}
+\let\bidi@excludedpackages\@empty
+\newcommand*{\bidi@saved@RequirePackage}{}
+\newcommand*{\bidi@PreventPackageFromLoading}{%
+ \@ifstar{\@bidi@PreventPackageFromLoading\PackageInfo}%
+ {\@bidi@PreventPackageFromLoading\PackageWarning}%
+}
+\newcommand*{\@bidi@PreventPackageFromLoading}[1]{%
+ \@ifnextchar [%]
+ {\@@bidi@PreventPackageFromLoading#1}{\@@bidi@PreventPackageFromLoading#1[]}%
+}
+\newcommand*{\@@bidi@PreventPackageFromLoading}{}
+
+\def\@@bidi@PreventPackageFromLoading#1[#2]#3{%
+ \edef\reserved@b{\zap@space#3 \@empty}%
+ \ifx \reserved@b\@empty
+ #1{biditools}{%
+ \string\bidi@PreventPackageFromLoading\space with empty packages\MessageBreak
+ argument ignored%
+ }%
+ \else
+ \ifx\bidi@excludedpackages\@empty
+ \let\bidi@saved@RequirePackage\RequirePackage
+ \let\RequirePackage\bidi@RequirePackage
+ \def\reserved@a##1##{%
+ \@latex@error
+ {\noexpand \usepackage before \string\documentclass}%
+ {\noexpand \usepackage may only appear in the document
+ preamble, i.e.,\MessageBreak
+ between \noexpand\documentclass and
+ \string\begin{document}.}%
+ \@gobble}%
+ \ifx\reserved@a\usepackage\else
+ \ifx\usepackage\bidi@saved@RequirePackage\else
+ \PackageWarning{biditools}{%
+ Maybe serious problem: unexpected definition of\MessageBreak
+ \string\usepackage
+ }%
+ \fi
+ \let\usepackage\RequirePackage
+ \fi
+ \fi
+ \expandafter\@for \expandafter\reserved@a\expandafter:\expandafter=%
+ \reserved@b\do {%
+ \ifx\reserved@a\@empty
+ #1{biditools}{%
+ empty package argument for
+ \string\bidi@PreventPackageFromLoading\MessageBreak
+ ignored%
+ }%
+ \else
+ \expandafter\@ifpackageloaded\expandafter{\reserved@a}{%
+ #1{biditools}{%
+ package `\reserved@a' already loaded.\MessageBreak
+ Cannot prevent it from beeing loaded%
+ }%
+ }{%
+ \edef\bidi@excludedpackages{\bidi@excludedpackages,%
+ \reserved@a}%
+ \if\relax\detokenize{#2}\relax\else
+ \@ifundefined{bidi@exclude@package@\reserved@a @do}{%
+ \@namedef{bidi@exclude@package@\reserved@a @do}{}%
+ }{}%
+ \expandafter\def
+ \csname bidi@exclude@package@\reserved@a
+ @do\expandafter\expandafter\expandafter\endcsname
+ \expandafter\expandafter\expandafter{%
+ \csname bidi@exclude@package@\reserved@a @do\endcsname
+ #2%
+ }%
+ \fi
+ }%
+ \fi
+ }%
+ \ifx\bidi@excludedpackages\@empty
+ \bidi@ResetPreventPackageFromLoading
+ \fi
+ \fi
+}
+
+\@onlypreamble\bidi@PreventPackageFromLoading
+\newcommand*{\bidi@ResetPreventPackageFromLoading}{%
+ \let\bidi@excludedpackages\@empty
+ \ifx\RequirePackage\bidi@RequirePackage
+ \ifx\usepackage\RequirePackage
+ \let\usepackage\bidi@saved@RequirePackage
+ \fi
+ \let\RequirePackage\bidi@saved@RequirePackage
+ \fi
+}
+\@onlypreamble\bidi@ResetPreventPackageFromLoading
+\newcommand*{\bidi@StorePreventPackageFromLoading}[1]{%
+ \let#1\bidi@excludedpackages
+}
+\@onlypreamble\bidi@StorePreventPackageFromLoading
+\newcommand*{\bidi@UnPreventPackageFromLoading}{%
+ \@ifstar {\@tempswatrue\@bidi@UnPreventPackageFromLoading}%
+ {\@tempswafalse\@bidi@UnPreventPackageFromLoading}%
+}
+
+\newcommand*{\@bidi@UnPreventPackageFromLoading}[1]{%
+ \edef\reserved@b{\zap@space#1 \@empty}%
+ \if@tempswa
+ \@for\reserved@a:=\reserved@b\do {%
+ \ifx\reserved@a\@empty \else
+ \ifcsname bidi@exclude@package@\reserved@a @do\endcsname
+ \expandafter\let
+ \csname bidi@exclude@package@\reserved@a @do\endcsname
+ \undefined
+ \fi
+ \fi
+ }%
+ \fi
+ \ifcsname bidi@excludedpackages\endcsname
+ \let\reserved@a\bidi@excludedpackages
+ \let\bidi@excludedpackages\@empty
+ \expandafter\@for\expandafter\reserved@c
+ \expandafter:\expandafter=\reserved@a
+ \do{%
+ \ifx\reserved@c\@empty\else
+ \@expandtwoargs\in@{,\reserved@c,}{,\reserved@b,}%
+ \ifin@
+ \else
+ \edef\bidi@excludedpackages{%
+ \bidi@excludedpackages,\reserved@c
+ }%
+ \fi
+ \fi
+ }%
+ \ifx\bidi@excludedpackages\@empty\bidi@ResetPreventPackageFromLoading\fi
+ \fi
+}
+
+
+\newcommand*{\bidi@RequirePackage}[2][]{%
+ \let\reserved@c\@empty
+ \let\reserved@d\@empty
+ \edef\reserved@b{\zap@space#2 \@empty}%
+ \expandafter\@for\expandafter\reserved@b\expandafter:\expandafter=\reserved@b
+ \do {%
+ \begingroup
+ \@tempswatrue
+ \@for\reserved@a:=\bidi@excludedpackages\do {%
+ \ifx\reserved@a\reserved@b
+ \@tempswafalse
+ \fi
+ }%
+ \if@tempswa
+ \xdef\reserved@c{\reserved@c,\reserved@b}%
+ \else
+ \ifx\reserved@b\@empty\else
+ \PackageInfo{biditools}{Excluding package `\reserved@b'\MessageBreak
+ from loading}%
+ \@ifundefined{bidi@exclude@package@\reserved@b @do}{%
+ }{%
+ \expandafter\g@addto@macro\expandafter\reserved@d
+ \csname bidi@exclude@package@\reserved@b @do\endcsname
+ }%
+ \fi
+ \fi
+ \endgroup
+ }%
+ \ifx\reserved@c\@empty
+ \let\reserved@a\bidi@gobbleopt
+ \else
+ \edef\reserved@a{\noexpand\bidi@saved@RequirePackage[#1]{%
+ \expandafter\@gobble\reserved@c\@empty}}%
+ \fi
+ \expandafter\reserved@d
+ \reserved@a
+}
+
+\newcommand{\bidi@gobbleopt}[1][]{}
+\AtEndDocument{%
+ \let\bidi@saved@checkend=\@checkend
+ \renewcommand*{\@checkend}[1]{%
+ \def\reserved@a{#1}\def\reserved@b{document}%
+ \bidi@saved@checkend{#1}%
+ \ifx\reserved@a\reserved@b
+ \let\bidi@saved@clearpage=\clearpage
+ \renewcommand*{\clearpage}{\bidi@saved@clearpage
+ \bidi@hook@bcma
+ \bidi@restore@newpage
+ \let\clearpage=\bidi@saved@clearpage}%
+ \fi%
+ \let\bidi@saved@dofilelist\@dofilelist
+ \def\@dofilelist{%
+ \bidi@hook@acma
+ \let\@dofilelist\bidi@saved@dofilelist
+ \bidi@saved@dofilelist
+ }%
+ }%
+}
+
+
+\newcommand*{\bidi@saved@checkend}{}
+\newcommand*{\bidi@saved@dofilelist}{}
+\newcommand*{\bidi@redefine@newpage}{%
+ \let\bidi@saved@newpage\newpage
+ \def\bidi@restore@newpage{%
+ \renewcommand*{\newpage}{%
+ \PackageWarningNoLine{%
+ biditools%
+ }{%
+ \string\newpage\space at main aux file!\MessageBreak
+ You have output material at the main aux file.\MessageBreak
+ Note, that the \string\bidi@BeforeClosingMainAux\space commands\MessageBreak
+ are processed before the output from aux file%
+ }%
+ \let\newpage\bidi@saved@newpage
+ \newpage
+ }%
+ }%
+ \renewcommand*{\newpage}{%
+ \PackageError{%
+ biditools%
+ }{%
+ \string\newpage\space at \string\bidi@BeforeClosingMainAux
+ }{%
+ You should never use \string\newpage\space or
+ \string\clear(double)page or other output material at the\MessageBreak
+ argument of \string\bidi@BeforeClosingMainAux!\MessageBreak
+ If you'll continue, the \string\newpage\space will be ignored to
+ avoid corruption of\MessageBreak
+ every prior use of \string\bidi@BeforeClosingMainAux.
+ }%
+ }%
+}
+
+\newcommand*{\bidi@restore@newpage}{}
+\newcommand*{\bidi@hook@bcma}{}
+\newcommand*{\bidi@hook@acma}{}
+\newcommand*{\bidi@BeforeClosingMainAux}{%
+ \ifx\bidi@hook@bcma\@empty
+ \gdef\bidi@hook@bcma{%
+ \renewcommand*{\bidi@BeforeClosingMainAux}[1]{####1}%
+ \let\protected@write\bidi@protected@immediate@write
+ \bidi@redefine@newpage
+ }%
+ \fi
+ \g@addto@macro\bidi@hook@bcma%
+}
+
+\newcommand*{\bidi@AfterReadingMainAux}{%
+ \ifx\bidi@hook@acma\@empty
+ \gdef\bidi@hook@acma{%
+ \renewcommand*{\bidi@AfterReadingMainAux}[1]{####1}%
+ \let\protected@write\bidi@protected@immediate@write
+ }%
+ \fi
+ \g@addto@macro\bidi@hook@acma%
+}
+
+\long\def\bidi@protected@immediate@write#1#2#3{%
+ \begingroup
+ #2%
+ \let\protect\@unexpandable@protect
+ \edef\reserved@a{\immediate\write#1{#3}}%
+ \reserved@a
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi
+}
+
+\def\bidi@patch@counter{0}%
+\if@bidi@csundef{numexpr}{%
+ \def\bidi@patch@stepcounter{%
+ \begingroup
+ \count@\bidi@patch@counter\relax
+ \advance\count@\@ne\relax
+ \edef\x{\endgroup
+ \noexpand\def\noexpand\bidi@patch@counter{\the\count@}%
+ }%
+ \x
+ }%
+}{%
+ \def\bidi@patch@stepcounter{%
+ \edef\bidi@patch@counter{%
+ \the\numexpr\bidi@patch@counter+\@ne\relax
+ }%
+ }%
+}
+\def\bidi@patch@list{}
+\def\bidi@patch@Add{%
+ \bidi@appto\bidi@patch@list
+}
+\def\bidi@patch@AfterPackage#1{%
+ \@ifpackageloaded{#1}{%
+ \@firstofone
+ }{%
+ \bidi@patch@AfterPackage{#1}%
+ }%
+}
+\def\bidi@patch@AfterPackage#1{%
+ \edef\bidi@patch@temp{#1}%
+ \bidi@patch@stepcounter
+ \expandafter\bidi@patch@@AfterPackage
+ \csname bidi@patch@\bidi@patch@counter\expandafter\endcsname{%
+ \bidi@patch@temp
+ }%
+}
+\def\bidi@patch@@AfterPackage#1#2#3{%
+ \begingroup
+ \toks@{#3}%
+ \xdef\bidi@patch@gtemp{%
+ \noexpand\@ifpackageloaded{#2}{%
+ \noexpand\let\noexpand#1\noexpand\relax
+ \the\toks@
+ }{}%
+ }%
+ \endgroup
+ \let#1\bidi@patch@gtemp
+ \bidi@patch@Add#1%
+ \bidi@patch@try{bidi@AfterPackage}{#2}#1%
+}
+
+\def\bidi@patch@try#1#2#3{%
+ \if@bidi@csundef{#1}{}{%
+ \csname #1\endcsname{#2}{#3}%
+ }%
+}
+
+\AtBeginDocument{\bidi@patch@list}
+
+\bidi@AtEndPreamble{\bidi@patch@list}%
+
+\bidi@AfterEndPreamble{%
+ \let\bidi@patch@OrgIfPackageLoaded\@ifpackageloaded
+ \let\bidi@patch@OrgIfPackageLater\@ifpackagelater
+ \let\bidi@patch@OrgIfClassLoaded\@ifclassloaded
+ \let\bidi@patch@OrgIfClassLater\@ifclasslater
+ \bidi@patch@list
+ \let\@ifpackageloaded\bidi@patch@OrgIfPackageLoaded
+ \let\@ifpackagelater\bidi@patch@OrgIfPackageLater
+ \let\@ifclassloaded\bidi@patch@OrgIfClassLoaded
+ \let\@ifclasslater\bidi@patch@OrgIfClassLater
+}%
% \end{macrocode}
% \iffalse
%</biditools.sty>
@@ -4771,7 +5293,7 @@ bidi implementation of tufte sidenote]
\RequirePackage{xifthen}
\RequirePackage{ragged2e}
\RequirePackage{setspace}
-\RequirePackage{hopatch}
+\RequirePackage{biditools}
\def\bidituftesidenotemarginpar{%
\ifhmode
\@bsphack
@@ -4984,7 +5506,7 @@ bidi implementation of tufte sidenote]
{\BR@bibitem[#1]{#2}}%
\BR@c@bibitem{#2}%
}
-\hopatch@AfterPackage{bidi}{\nobibliography*} % pre-loads the bibliography keys
+\bidi@patch@AfterPackage{bidi}{\nobibliography*} % pre-loads the bibliography keys
%%
% Normal \cite behavior
\newcounter{@bidituftesidenote@num@bibkeys}%
@@ -5096,12 +5618,12 @@ bidi implementation of tufte sidenote]
\renewcommand{\footnotelayout}{\@bidituftesidenote@sidenote@font\@bidituftesidenote@sidenote@justification}
% Override footmisc's definition to set the sidenote marks (numbers) inside the
% sidenote's text block.
-\hopatch@AfterPackage{bidi}{\long\def\@makefntext#1{\@textsuperscript{\@bidituftesidenote@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1}}
+\bidi@patch@AfterPackage{bidi}{\long\def\@makefntext#1{\@textsuperscript{\@bidituftesidenote@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1}}
% Set the in-text footnote mark in the same typeface as the body text itself.
-\hopatch@AfterPackage{bidi}{\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}}
+\bidi@patch@AfterPackage{bidi}{\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}}
\providecommand*{\multiplefootnotemarker}{3sp}
\providecommand*{\multfootsep}{,}
-\hopatch@AfterPackage{bidi}{%
+\bidi@patch@AfterPackage{bidi}{%
\renewcommand{\@footnotemark}{%
\leavevmode%
\ifhmode%
@@ -5122,7 +5644,7 @@ bidi implementation of tufte sidenote]
\spacefactor\@x@sf\relax%
\fi
}
-\hopatch@AfterPackage{bidi}{%
+\bidi@patch@AfterPackage{bidi}{%
\renewcommand\@footnotetext[2][0pt]{%
\bidituftesidenotemarginpar{%
\hbox{}\vspace*{#1}%
@@ -5270,7 +5792,7 @@ bidi implementation of tufte sidenote]
\newcommand{\sidenote}{\optparams{\@bidituftesidenote@sidenote}{[][0pt]}}
\newcommand{\LTRsidenote}{\optparams{\@LTRbidituftesidenote@sidenote}{[][0pt]}}
\newcommand{\RTLsidenote}{\optparams{\@RTLbidituftesidenote@sidenote}{[][0pt]}}
-\hopatch@AfterPackage{bidi}{%
+\bidi@patch@AfterPackage{bidi}{%
\renewcommand{\footnote}{\optparams{\@bidituftesidenote@sidenote}{[][0pt]}}%
\renewcommand{\LTRfootnote}{\optparams{\@LTRbidituftesidenote@sidenote}{[][0pt]}}%
\renewcommand{\RTLfootnote}{\optparams{\@RTLbidituftesidenote@sidenote}{[][0pt]}}%
@@ -5314,7 +5836,7 @@ bidi implementation of tufte sidenote]
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bidituftetoc}[2011/06/17 v0.1
bidi implementation of tufte toc]
-\RequirePackage{titlesec,titletoc,xifthen,hopatch}
+\RequirePackage{titlesec,titletoc,xifthen,biditools}
\newcommand{\@bidituftetoc@pkgname}{bidituftetoc}
\newcommand{\bidituftetocError}[2]{\PackageError{\@bidituftetoc@pkgname}{#1}{#2}}
%%
@@ -5327,7 +5849,7 @@ bidi implementation of tufte toc]
\ProcessOptions
%%
% Make Tuftian-style section headings and TOC formatting
-\hopatch@AfterPackage{bidi}{%
+\bidi@patch@AfterPackage{bidi}{%
\titleformat{\chapter}%
[display]% shape
{\relax\ifthenelse{\NOT\boolean{@bidituftefloat@symmetric}}{\begin{fullwidth}}{}}% format applied to label+text
@@ -5383,7 +5905,7 @@ bidi implementation of tufte toc]
% Formatting for main TOC (printed in front matter)
% {section} [left] {above} {before w/label} {before w/o label} {filler + page} [after]
\ifthenelse{\boolean{@bidituftetoc@toc}}{%
- \hopatch@AfterPackage{bidi}{%
+ \bidi@patch@AfterPackage{bidi}{%
\titlecontents{part}% FIXME
[0em] % distance from left margin
{\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape} % above (global formatting of entry)
@@ -5648,7 +6170,7 @@ bidi implementation of tufte title]
\newcommand{\thanklesspublisher}{}% full publisher minus \thanks{}
\newcommand{\@publisher}{}% full publisher with \thanks{}
\newcommand{\thedate}{\today}
-\hopatch@AfterPackage{bidi}{%
+\bidi@patch@AfterPackage{bidi}{%
\renewcommand{\thanks}[1]{\footnote{#1}}
\renewcommand{\LTRthanks}[1]{\LTRfootnote{#1}}
\renewcommand{\RTLthanks}[1]{\RTLfootnote{#1}}