summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/bidi/footnote-xetex-bidi.def
blob: c612599becbc43932b6e4eb1c83ce982d8b47435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
%%
%% This is file `footnote-xetex-bidi.def',

%% 
%%   __________________________________
%%   Copyright © 2009-2010 Vafa Khalighi
%% 
%%   License information appended.
%% 
%% 
\ProvidesFile{footnote-xetex-bidi.def}[2010/07/25 v0.5 bidi footnote macros for XeTeX engine]
\if@RTLmain\@RTL@footnotetrue\else\@RTL@footnotefalse\fi
\def\bidi@footnote@output{{%
    \dimen0=\ht\footins
    \advance\dimen0 by\dp\footins
    \def\@elt##1##2{%
      \ifx\bidi@footnoterule\relax\global\let\bidi@footnoterule##2\fi
      \advance\dimen0 by -##1\relax
      \ifdim\dimen0<\z@
        {%
  \let\@elt\relax\let\right@footnote\relax\let\left@footnote\relax
  \dimen0=-\dimen0%
  \xdef\new@bidi@footnote@list{\new@bidi@footnote@list\noexpand\@elt{\the\dimen0}{##2}}%
}%
      \fi
      \ifdim\dimen0>\z@\else
\let\right@footnote\relax\let\left@footnote\relax
\def\@elt####1####2{%
  {\let\@elt\relax
  \xdef\new@bidi@footnote@list{\new@bidi@footnote@list\noexpand\@elt{####1}{####2}}}%
}%
      \fi
    }%
    \def\new@bidi@footnote@list{}%
    \bidi@footnote@list
    \global\let\bidi@footnote@list\new@bidi@footnote@list
  }}
\def\right@footnote{%
  \hbox to \columnwidth
  {\beginR \vbox{\kern -3\p@
   \hrule width .4\columnwidth \kern2.6\p@}\hfil\endR}}
\def\left@footnote{%
   \hrule width .4\columnwidth\kern 2.6\p@}
\def\textwidth@footnote{\kern-3\p@
  \hrule \@width \textwidth \kern 2.6\p@}
\def\right@footnoterule{\bidi@footnote@output\right@footnote\global\let\bidi@footnoterule\relax}
\def\left@footnoterule{\bidi@footnote@output\left@footnote\global\let\bidi@footnoterule\relax}
\def\textwidth@footnoterule{\bidi@footnote@output\textwidth@footnote\global\let\bidi@footnoterule\relax}
\def\auto@footnoterule{\bidi@footnote@output
  \ifx\bidi@footnoterule\relax\if@RTL\right@footnote\else\left@footnote\fi\else\bidi@footnoterule\fi
  \global\let\bidi@footnoterule\relax}
\def\leftfootnoterule{\def\footnoterule{\left@footnoterule}}
\let\LRfootnoterule=\leftfootnoterule
\def\rightfootnoterule{\def\footnoterule{\right@footnoterule}}
\def\textwidthfootnoterule{\def\footnoterule{\textwidth@footnoterule}}
\def\autofootnoterule{\def\footnoterule{\auto@footnoterule}}
\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}
\def\bidi@footnote@list{}
\let\bidi@footnoterule\relax
\def\RTLfootnote{\@ifnextchar[\@xRTLfootnote{\stepcounter\@mpfn
     \protected@xdef\@thefnmark{\thempfn}%
     \@footnotemark\@RTLfootnotetext}}
\def\@xRTLfootnote[#1]{%
   \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
   \endgroup
   \@footnotemark\@RTLfootnotetext}
\def\LTRfootnote{\@ifnextchar[\@xLTRfootnote{\stepcounter\@mpfn
     \protected@xdef\@thefnmark{\thempfn}%
     \@footnotemark\@LTRfootnotetext}}
\def\@xLTRfootnote[#1]{%
   \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
   \endgroup
   \@footnotemark\@LTRfootnotetext}
\def\insertRTL{\bgroup\beginR\@RTLtrue}
\def\endinsertRTL{\endR\egroup}
\def\insertLTR{\bgroup\beginL\@RTLfalse}
\def\endinsertLTR{\endL\egroup}
\DeclareRobustCommand\InLTR{\insertLTR}
\DeclareRobustCommand\EInLTR{\endinsertLTR}
\DeclareRobustCommand\InRTL{\insertRTL}
\DeclareRobustCommand\EInRTL{\endinsertRTL}
\long\def\parse@lsent#1#2\EInLTR#3#4#5\parse@end{\@sentdirfalse
\def\@tempa{\InLTR}\def\@tempb{\EInLTR}\def\@tempc{#1}\def\@tempd{#4}%
\ifx\@tempa\@tempc\ifx\@tempb\@tempd\@sentdirtrue\fi\fi}
\long\def\parse@rsent#1#2\EInRTL#3#4#5\parse@end{\@sentdirfalse
\def\@tempa{\InRTL}\def\@tempb{\EInRTL}\def\@tempc{#1}\def\@tempd{#4}%
\ifx\@tempa\@tempc\ifx\@tempb\@tempd\@sentdirtrue\fi\fi}
\long\def\iflsentence#1{\parse@lsent#1\EInLTR123\parse@end\if@sentdir}
\long\def\ifrsentence#1{\parse@rsent#1\EInRTL123\parse@end\if@sentdir}
\long\def\bidi@footnotetext@dir#1{%
   \@tempswatrue
   \ifrsentence{#1}\rtl\@tempswafalse\fi
   \iflsentence{#1}\ltr\@tempswafalse\fi
   \if@tempswa\if@RTL\rtl\else\ltr\fi\fi
   \xdef\bidi@this@footnote{\if@RTL\noexpand\right@footnote\else\noexpand\left@footnote\fi}%
}
\def\bidi@footnotetext@after{%
   {%
     \let\@elt\relax\let\right@footnote\relax\let\left@footnote\relax
     \dimen0=\ht\footins
     \advance\dimen0 by\dp\footins
     \xdef\bidi@footnote@list{\bidi@footnote@list\@elt{\the\dimen0}{\bidi@this@footnote}}%
   }%
}
\def\setfootnoteRL{\@RTL@footnotetrue}
\def\unsetfootnoteRL{\@RTL@footnotefalse}
\def\setfootnoteLR{\unsetfootnoteRL}
\long\def\@footnotetext#1{%
    \begingroup
    \setbox\footins
    \vbox{\if@RTL@footnote\@RTLtrue\else\@RTLfalse\fi\reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
    \bidi@footnotetext@dir{#1}%
    \protected@edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces#1\strut}}%
     \bidi@footnotetext@after
    \insert\footins{\unvbox\footins}%
    \endgroup}
\long\def\@RTLfootnotetext#1{%
    \begingroup
    \setbox\footins
    \vbox{\@RTLtrue\reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
    \bidi@footnotetext@dir{#1}%
    \protected@edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces #1\strut}}%
     \bidi@footnotetext@after
    \insert\footins{\unvbox\footins}%
    \endgroup}
\long\def\@LTRfootnotetext#1{%
    \begingroup
    \setbox\footins
    \vbox{\@RTLfalse\reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
    \bidi@footnotetext@dir{#1}%
    \protected@edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces#1\strut}}%
     \bidi@footnotetext@after
    \insert\footins{\unvbox\footins}%
    \endgroup}
\long\def\@mpRTLfootnotetext#1{%
  \global\setbox\@mpfootins\vbox{\@RTLtrue%
    \unvbox\@mpfootins
    \reset@font\footnotesize
    \hsize\columnwidth
    \@parboxrestore
    \protected@edef\@currentlabel
         {\csname p@mpfootnote\endcsname\@thefnmark}%
    \color@begingroup
     \bidi@footnotetext@dir{#1}
    \ifnum\c@mpfootnote=1\if@RTL\global\let\bidi@footnoterule\right@footnote\else\global\let\bidi@footnoterule\left@footnote\fi\fi
      \@makefntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
    \color@endgroup}}
\long\def\@mpLTRfootnotetext#1{%
  \global\setbox\@mpfootins\vbox{\@RTLfalse%
    \unvbox\@mpfootins
    \reset@font\footnotesize
    \hsize\columnwidth
    \@parboxrestore
    \protected@edef\@currentlabel
         {\csname p@mpfootnote\endcsname\@thefnmark}%
    \color@begingroup
     \bidi@footnotetext@dir{#1}
    \ifnum\c@mpfootnote=1\if@RTL\global\let\bidi@footnoterule\right@footnote\else\global\let\bidi@footnoterule\left@footnote\fi\fi
      \@makefntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
    \color@endgroup}}
\long\def\@mpfootnotetext#1{%
  \global\setbox\@mpfootins\vbox{\if@RTL@footnote\@RTLtrue\else\@RTLfalse\fi%
    \unvbox\@mpfootins
    \reset@font\footnotesize
    \hsize\columnwidth
    \@parboxrestore
    \protected@edef\@currentlabel
         {\csname p@mpfootnote\endcsname\@thefnmark}%
    \color@begingroup
     \bidi@footnotetext@dir{#1}
    \ifnum\c@mpfootnote=1\if@RTL\global\let\bidi@footnoterule\right@footnote\else\global\let\bidi@footnoterule\left@footnote\fi\fi
      \@makefntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
    \color@endgroup}}
\def\@iiiminipage#1#2[#3]#4{%
  \leavevmode
  \@pboxswfalse
  \setlength\@tempdima{#4}%
  \def\@mpargs{{#1}{#2}[#3]{#4}}%
  \setbox\@tempboxa\vbox\bgroup\hbox\bgroup\if@RTL\beginL\fi\vbox\bgroup
    \color@begingroup
      \hsize\@tempdima
      \textwidth\hsize \columnwidth\hsize
      \@parboxrestore
      \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
      \let\@footnotetext\@mpfootnotetext
      \let\@LTRfootnotetext\@mpLTRfootnotetext
      \let\@RTLfootnotetext\@mpRTLfootnotetext
      \let\@listdepth\@mplistdepth \@mplistdepth\z@
      \@minipagerestore
      \@setminipage}
\def\LTRthanks#1{\footnotemark
    \protected@xdef\@thanks{\@thanks
        \protect\LTRfootnotetext[\the\c@footnote]{#1}}%
}
\def\LTRfootnotetext{%
     \@ifnextchar [\@xLTRfootnotenext
       {\protected@xdef\@thefnmark{\thempfn}%
    \@LTRfootnotetext}}
\def\@xLTRfootnotenext[#1]{%
  \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
  \endgroup
  \@LTRfootnotetext}
\def\RTLthanks#1{\footnotemark
    \protected@xdef\@thanks{\@thanks
        \protect\RTLfootnotetext[\the\c@footnote]{#1}}%
}
\let\@thanks\@empty
\def\RTLfootnotetext{%
     \@ifnextchar [\@xRTLfootnotenext
       {\protected@xdef\@thefnmark{\thempfn}%
    \@RTLfootnotetext}}
\def\@xRTLfootnotenext[#1]{%
  \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
  \endgroup
  \@RTLfootnotetext}
\leftfootnoterule
%% 
%% Copyright © 2009-2010      by Vafa Khalighi     <vafakh84@gmail.com>
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status)
%% by Vafa Khalighi.
%% 
%% 
%% 
%% 
%%
%% End of file `footnote-xetex-bidi.def'.