summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luabidi/tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-10-29 03:00:39 +0000
committerNorbert Preining <norbert@preining.info>2019-10-29 03:00:39 +0000
commit97f5151099967e6c823d640a90d87bca92c44035 (patch)
tree685caa49488599f87d0caa4e972833b2263d8567 /macros/luatex/latex/luabidi/tex
parent25a647b97ef526aefcc75269dd19c46dbe3ae4c1 (diff)
CTAN sync 201910290300
Diffstat (limited to 'macros/luatex/latex/luabidi/tex')
-rw-r--r--macros/luatex/latex/luabidi/tex/arabmaths.tex2
-rw-r--r--macros/luatex/latex/luabidi/tex/autofootnoterule.tex116
-rw-r--r--macros/luatex/latex/luabidi/tex/luabidi-arabmaths.def11
-rw-r--r--macros/luatex/latex/luabidi/tex/luabidi-autofootnoterule.def72
-rw-r--r--macros/luatex/latex/luabidi/tex/luabidi-footnotes.def76
-rw-r--r--macros/luatex/latex/luabidi/tex/luabidi.sty52
-rw-r--r--macros/luatex/latex/luabidi/tex/textwidthfootnoterule.tex2
7 files changed, 197 insertions, 134 deletions
diff --git a/macros/luatex/latex/luabidi/tex/arabmaths.tex b/macros/luatex/latex/luabidi/tex/arabmaths.tex
deleted file mode 100644
index e125dce795..0000000000
--- a/macros/luatex/latex/luabidi/tex/arabmaths.tex
+++ /dev/null
@@ -1,2 +0,0 @@
-\mathdir TRT
-\def\@eqnnum{{\normalfont \normalcolor \textdir TLT ({\textdir TRT\theequation})}}
diff --git a/macros/luatex/latex/luabidi/tex/autofootnoterule.tex b/macros/luatex/latex/luabidi/tex/autofootnoterule.tex
deleted file mode 100644
index f770694652..0000000000
--- a/macros/luatex/latex/luabidi/tex/autofootnoterule.tex
+++ /dev/null
@@ -1,116 +0,0 @@
-\ifx \CatEscape\undefined
- \chardef\CatEscape=0
- \chardef\CatOpen=1
- \chardef\CatClose=2
- \chardef\CatIgnore=9
- \chardef\CatLetter=11
- \chardef\CatOther=12
- \chardef\CatActive=13 % is defined in Plain already
-
- \chardef\CatUsCode=\catcode`\_
-\fi
-
-\catcode`\_=\CatLetter % top level macro file
-
-
-\def\l@fn{%
- \hbox to \columnwidth
- {\pagedir TLT\vbox{\kern -3\p@
- \hrule width .4\columnwidth \kern2.6\p@}\hfil}}
-\def\r@fn{%
- \hrule width .4\columnwidth\kern 2.6\p@}
-
-
-\def\@makefnmark{\hbox{$^{\hbox{\scriptsize\@thefnmark}}\m@th$}}
-
-
-\def\leftfootnoterule{\global\def\footnoterule{\l@fn}}
-\def\rightfootnoterule{\global\def\footnoterule{\r@fn}}
-\leftfootnoterule
-
-%%% \beginprog
-\newread\old_foot_file
-\newwrite\foot_file
-\def\foot_file_name{\jobname.fot\relax}
-\def\init_footnote{%
- \openin\old_foot_file\foot_file_name
- \ifeof\old_foot_file \closein\old_foot_file
- \else \closein\old_foot_file
- \read_foot_file
- \fi
- \immediate\openout\foot_file\foot_file_name
- \immediate\write\foot_file{\relax}%
- \global\let\init_footnote\relax
- }
-
-\newcount\foot_name_no % for generating footnote mark names
-
-
-
-
-
-\newcount\autofootnote
-\def\fnpp_next_footnote{%
- \init_footnote
- \global\advance\foot_name_no\@ne
- \global\advance\c@footnote\@ne
- \edef\do_write{%
- \immediate\write\foot_file{%
- \string\advance\autofootnote\@ne
- \string\expandafter\xdef
- \string\csname\space f@\number\foot_name_no \endcsname{%
- \string\number\autofootnote
- }%
- }%
- }%
- \do_write
- \global\autofootnote 0\csname f@\number\foot_name_no \endcsname \relax
- }
-
-\def\read_foot_file{%
- \begingroup
- \catcode`\@\CatLetter \catcode`\^^M\CatIgnore
- \input \foot_file_name
- \endgroup
- }
-
-\let\fnpp_orig_outputpage=\@outputpage
-\def\@outputpage{%
- \ifx \init_footnote\relax
- \immediate\write\foot_file{\autofootnote\z@}%
- \fi
- \fnpp_orig_outputpage
- }
-
-\let\FnppOrigFootnote=\footnote % save original bindings
-\let\FnppOrigFootnotemark=\footnotemark
-
-\def\footnote{%
- \@ifnextchar[% % ] (Emacs)
- \@xfootnote
- {\fnpp_next_footnote \ifnum\autofootnote=1\rightfootnoterule\fi \@xfootnote[\the\c@footnote] %
-}%
- }
-\def\footnotemark{%
- \@ifnextchar[% % ] (Emacs)
- \@xfootnotemark
- {\fnpp_next_footnote \ifnum\autofootnote=1\rightfootnoterule\fi \@xfootnotemark[\the\c@footnote]}%
- }
-
-
-
-
-\def\footnotemarkLR{%
- \@ifnextchar[% % ] (Emacs)
- \@xfootnotemark
- {\fnpp_next_footnote \ifnum\autofootnote=1\leftfootnoterule\fi\@xfootnotemark[\the\c@footnote]}%
- }
-
-
-\def\Footnote#1{%
-\begingroup
-\footnotemarkLR%
-\renewcommand{\thefootnote}{\@arabic\c@footnote}%
-\pardir TLT \textdir TLT\footnotetext{#1}%
-\endgroup
-}
diff --git a/macros/luatex/latex/luabidi/tex/luabidi-arabmaths.def b/macros/luatex/latex/luabidi/tex/luabidi-arabmaths.def
new file mode 100644
index 0000000000..8e2eaf3028
--- /dev/null
+++ b/macros/luatex/latex/luabidi/tex/luabidi-arabmaths.def
@@ -0,0 +1,11 @@
+%% This file is luabidi-arabmaths.def
+%% This is part of the luabidi package
+%%
+%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller
+%%
+%%%% It may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+
+\mathdir TRT
+\def\@eqnnum{{\normalfont \normalcolor \textdir TLT ({\textdir TRT\theequation})}}
diff --git a/macros/luatex/latex/luabidi/tex/luabidi-autofootnoterule.def b/macros/luatex/latex/luabidi/tex/luabidi-autofootnoterule.def
new file mode 100644
index 0000000000..a9f0cbe21f
--- /dev/null
+++ b/macros/luatex/latex/luabidi/tex/luabidi-autofootnoterule.def
@@ -0,0 +1,72 @@
+%% This file is luabidi-autofootnoterule.def
+%% This is part of the luabidi package
+%%
+%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller
+%%
+%%%% It may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+
+
+%
+% Determine first footnote on current page
+%
+
+\RequirePackage{perpage}
+\newcounter{pagefnt}
+\setcounter{pagefnt}{0}
+\MakePerPage[0]{pagefnt}
+
+
+%
+% Footnote redefinitions
+%
+
+% Save original definitions
+\let\FnppOrigFootnote=\footnote
+\let\FnppOrigFootnotemark=\footnotemark
+
+% Default: left-aligned rule
+\leftfootnoterule
+
+% \footnote
+\def\footnote{%
+ \@ifnextchar[% % ] (Editor)
+ \@xfootnote
+ {\stepcounter\@mpfn\stepcounter{pagefnt}%
+ \ifnum\value{pagefnt}=0%
+ \if@RTL%
+ \rightfootnoterule%
+ \else%
+ \leftfootnoterule%
+ \fi%
+ \fi%
+ \@xfootnote[\the\c@footnote]%
+ }%
+}
+
+% \RTLfootnote
+\def\footnotemarkRL{%
+ \@ifnextchar[% % ] (Editor)
+ \@xfootnotemark
+ {\stepcounter\@mpfn\stepcounter{pagefnt}%
+ \ifnum\value{pagefnt}=0%
+ \rightfootnoterule%
+ \fi%
+ \@xfootnotemark[\the\c@footnote]%
+ }%
+}
+
+% \LTRfootnote
+\def\footnotemarkLR{%
+ \@ifnextchar[% % ] (Editor)
+ \@xfootnotemark
+ {\stepcounter\@mpfn\stepcounter{pagefnt}%
+ \ifnum\value{pagefnt}=0%
+ \leftfootnoterule%
+ \fi%
+ \@xfootnotemark[\the\c@footnote]%
+ }%
+}
+
+% Finis
diff --git a/macros/luatex/latex/luabidi/tex/luabidi-footnotes.def b/macros/luatex/latex/luabidi/tex/luabidi-footnotes.def
new file mode 100644
index 0000000000..db185e2578
--- /dev/null
+++ b/macros/luatex/latex/luabidi/tex/luabidi-footnotes.def
@@ -0,0 +1,76 @@
+%% This file is luabidi-footnotes.def
+%% This is part of the luabidi package
+%%
+%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller
+%%
+%%%% It may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+
+%
+% Footnotes
+%
+
+% These are defined in polyglossia. Provide simple fallbacks
+\providecommand*\localnumeral{\@ifstar\@@localnumeral\@localnumeral}
+
+\providecommand*\@localnumeral[1]{#1}
+\providecommand*\@@localnumeral[1]{%
+ \protect\@arabic\csuse{c@#1}%
+}
+
+\let\footnotemarkLR\footnotemark
+\let\footnotemarkRL\footnotemark
+
+\providecommand\LTRfootnote[2][]{%
+ \begingroup
+ \ifx#1\\\\\footnotemarkLR
+ \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
+ \else%
+ \footnotemarkLR[#1]%
+ \renewcommand{\thefootnote}{\localnumeral{#1}}%
+ \fi
+ \pardir TLT \textdir TLT\footnotetext{#2}%
+ \endgroup
+}
+
+\providecommand\RTLfootnote[2][]{%
+ \begingroup
+ \ifx#1\\\\\footnotemarkRL%
+ \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
+ \else%
+ \footnotemarkRL[#1]%
+ \renewcommand{\thefootnote}{\localnumeral{#1}}%
+ \fi
+ \pardir TRT \textdir TRT\footnotetext{#2}%
+ \endgroup
+}
+
+% backwards compatibility
+\def\Footnote#1{\LTRfootnote{#1}}
+
+%
+% Footnote rules
+%
+
+% adjustable rule length
+\newlength\footnoterulewidth
+\setlength\footnoterulewidth{.4\columnwidth}
+
+% The left, right and full width rules
+\def\luabidi@left@fn{%
+ \hbox to \columnwidth
+ {\pagedir TLT\textdir TLT\vbox{\kern -3\p@
+ \hrule\@width\footnoterulewidth\kern2.6\p@}\hfil}}
+\def\luabidi@right@fn{%
+ \pagedir TRT\textdir TRT\hrule\@width\footnoterulewidth\kern2.6\p@}
+\def\luabidi@textwidth@fn{%
+ \kern-3\p@\hrule\@width\textwidth\kern2.6\p@}
+
+% switches for the rule position
+\def\leftfootnoterule{\global\def\footnoterule{\luabidi@left@fn}}
+\def\rightfootnoterule{\global\def\footnoterule{\luabidi@right@fn}}
+\def\textwidthfootnoterule{\global\def\footnoterule{\luabidi@textwidth@fn}}
+\def\autofootnoterule{\luabidi@autofootnoteruletrue}
+
+% Finis
diff --git a/macros/luatex/latex/luabidi/tex/luabidi.sty b/macros/luatex/latex/luabidi/tex/luabidi.sty
index abc1d2a936..4277a1f173 100644
--- a/macros/luatex/latex/luabidi/tex/luabidi.sty
+++ b/macros/luatex/latex/luabidi/tex/luabidi.sty
@@ -1,4 +1,5 @@
%% This file is luabidi.sty
+%% This is part of the luabidi package
%%
%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller
%%
@@ -6,11 +7,30 @@
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luabidi}[2019/08/24 v0.4
+\ProvidesPackage{luabidi}[2019/10/27 v0.5
Bidirectional typesetting in LuaTeX]
+
+\RequirePackage{etoolbox}
+
+%
+% Package options
+%
+
+\DeclareOption{arabmaths}{\input{luabidi-arabmaths.def}}
+\newif\ifluabidi@autofootnoterule
+\DeclareOption{autofootnoterule}{\luabidi@autofootnoteruletrue}
+\newif\ifluabidi@textwidthfootnoterule
+\DeclareOption{textwidthfootnoterule}{\luabidi@textwidthfootnoteruletrue}
+\ProcessOptions
+
+%
+% General command and switches
+%
+
\newif\if@RTL
\newif\if@RTLmain
-\def\setRTLmain{\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT}
+\@RTLmainfalse
+\def\setRTLmain{\@RTLmaintrue\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT}
\def\setRTL{\@RTLtrue\pardir TRT \textdir TRT}
\let\setRL=\setRTL
\def\setLTR{\@RTLfalse\pardir TLT \textdir TLT}
@@ -25,9 +45,6 @@
\def\@ensure@LTR#1{\if@RTL\LRE{#1}\else{#1}\fi}
\def\@ensure@dir#1{\if@RTL\RLE{#1}\else{#1}\fi}
\let\@ensure@maindir=\@ensuredir
-\@RTLmainfalse
-\DeclareOption{arabmaths}{\input{arabmaths}}
-\DeclareOption{textwidthfootnoterule}{\input{textwidthfootnoterule}}
\let\n@xt=\
\DeclareRobustCommand*\LRE{\protect\pLRE}
\def\pLRE{\protect\afterassignment\moreLRE \let\n@xt= }
@@ -39,18 +56,25 @@
\def\moreRLE{\bracetext \aftergroup\unsetRTL \setRTL\@RTLtrue}
\let\LR=\LRE
\let\RL=\RLE
+\def\hboxR#1{\hbox{\RL{#1}}}
-\def\Footnote#1{%
-\begingroup
-\footnotemark
-\renewcommand{\thefootnote}{\@arabic\c@footnote}%
-\pardir TLT \textdir TLT\footnotetext{#1}%
-\endgroup
-}
+%
+% Footnotes
+%
-\DeclareOption{autofootnoterule}{\input{autofootnoterule}}
+\input{luabidi-footnotes.def}
+\ifluabidi@textwidthfootnoterule
+ \textwidthfootnoterule
+\fi
+% This needs to be loaded late because of the switch
+\AtEndPreamble{%
+ \makeatletter
+ \ifluabidi@autofootnoterule
+ \input{luabidi-autofootnoterule.def}
+ \fi
+ \makeatother
+}
-\ProcessOptions
\endinput
diff --git a/macros/luatex/latex/luabidi/tex/textwidthfootnoterule.tex b/macros/luatex/latex/luabidi/tex/textwidthfootnoterule.tex
deleted file mode 100644
index 7fc71e0cef..0000000000
--- a/macros/luatex/latex/luabidi/tex/textwidthfootnoterule.tex
+++ /dev/null
@@ -1,2 +0,0 @@
-\def\footnoterule{\kern-3\p@
- \hrule \@width \textwidth \kern 2.6\p@}