summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/bidi/bidi.sty
blob: 94e1372d140903094d7252feb2aafedaa51b64db (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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
%%
%% This is file `bidi.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bidi.dtx  (with options: `table,bidi.sty')
%% 
%%   __________________________________________________
%%   Copyright (c) 2009--2018  Vafa Khalighi <persian-tex@tug.org>
%% 
%%   It may be distributed and/or modified 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 “author-maintained” (as per LPPL maintenance status)
%%   by Vafa Khalighi.
%% 
%% 
%% \CheckSum{49990}
%% \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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\NeedsTeXFormat{LaTeX2e}
\def\bididate{2018/10/12}
\def\bidi@version{34.9}
\ProvidesPackage{bidi}[\bididate\space v\bidi@version\space
Bidirectional typesetting in plain TeX and LaTeX]
\edef\@bidi@info{****************************************************^^J%
* ^^J%
* bidi package (Bidirectional typesetting in^^J%
* plain TeX and LaTeX, using XeTeX engine)^^J%
* ^^J%
* Description: A convenient interface for^^J%
* typesetting bidirectional texts in plain TeX^^J%
* and LaTeX.  The package includes adaptations^^J%
* for use with many other commonly-used packages.^^J%
* ^^J%
* Copyright (c) 2009--2018 Vafa Khalighi^^J%
* ^^J%
* v\bidi@version, \bididate^^J%
* ^^J%
* License: LaTeX Project Public License, version^^J%
* 1.3c or higher (your choice)^^J%
* ^^J%
* Location on CTAN: /macros/xetex/latex/bidi^^J%
* ^^J%
* Issue tracker: https://sourceforge.net/p/persian-tex-dist/tickets^^J%
* ^^J%
* Support: http://tug.org/mailman/listinfo/persiantex^^J%
* ^^J%
****************************************************}
\typeout{\@bidi@info}
\edef\bidi@everyjob{\the\everyjob}
\everyjob{\bidi@everyjob\typeout{\@bidi@info}}
\newcommand*{\bidiversion}{\ensuremath\bidi@version}
\newcommand*{\IfbidiPackageVersionLater}[1]{%
  \ifdim\bidi@version pt > #1 pt %
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\newcommand*{\IfbidiPackageVersionBefore}[1]{%
  \ifdim\bidi@version pt < #1 pt %
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\newcommand*{\IfbidiPackageVersion}[1]{%
  \ifdim\bidi@version pt = #1 pt %
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\RequirePackage{iftex}
\RequireXeTeX
\RequirePackage{biditools}
\RequirePackage{zref-abspage}
\RequirePackage{auxhook}
\RequirePackage{ltxcmds}
\RequirePackage{xkeyval}
\eqnewif{\if@RTLmain}{\if@rlmain}
\eqnewif{\if@RTL}{\if@rl}
\newif\if@nonlatin
\newif\if@bidi@perpage@footnote
\newcommand*{\setlatin}{\@nonlatinfalse}
\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
\newif\if@RTLmarginpar
\newif\if@LTRmarginpar
\newif\if@LTRbibitems
\newif\if@RTLbibitems
\newif\if@extrafootnotefeatures
\newif\if@RTLcolumnfootnotes
\eqnewif{\if@RTL@footnote}{\if@rl@footnote}
\newif\if@bidi@list@minipage@parbox
\newif\if@bidi@list@minipage@parbox@not@nob
\newcommand*{\@bidi@pdfcreator}{%
  The bidi package, v\bidi@version, \bididate
}
\newcommand*{\@bidi@pdfproducer}{%
  The bidi package, v\bidi@version, \bididate
}
\newcommand*{\@bidi@pdfcustomproperties}{%
  This is the bidi package, Version \bidi@version,
  Released October 12, 2018.
}
\@RTLmainfalse
\AtBeginDocument{%
  \if@RTLmain\else
    \if@RTL\@RTLmaintrue%
    \else\@RTLmainfalse%
    \fi%
  \fi%
}
\let\n@xt=\
\bidi@newrobustcmd*{\LRE}{\protect\pLRE}%
\def\pLRE{\protect\afterassignment\moreLRE \let\n@xt= }
\bidi@newrobustcmd*{\RLE}{\protect\pRLE}
\def\pRLE{\protect\afterassignment\moreRLE \let\n@xt= }
\def\bracetext{\ifcat\n@xt{\else\ifcat\n@xt}\fi
  \errmessage{Missing left brace has been substituted}\fi \bgroup}
\newinsert\@bidi@copyins@
\skip\@bidi@copyins@=12\p@
\dimen\@bidi@copyins@=40pc
\count\@bidi@copyins@=1000
\newcommand*{\@bidi@inslogo@}{\insert\@bidi@copyins@{\@bidi@logo@}}
\newcommand*{\@bidi@logo@hb@xt@columnwidth}{%
  \if@RTLmain
    \if@twocolumn
      \hboxR to \columnwidth
    \else
      \hboxR to \textwidth
    \fi
  \else
    \if@twocolumn
      \hboxL to \columnwidth
    \else
      \hboxL to \textwidth
    \fi
  \fi
}
\newcommand*{\@bidi@logo}[1]{%
  \toks@{%
    \setbox\z@\hbox{%
      \special{%
        pdf:image width 50pt height 50pt (#1)%
      }
    }%
    \dp\z@\z@
    \ht\z@=50pt
    \wd\z@=50pt
    \beginL
      \lower20pt\box\z@
    \endL
  }%
  \the\toks@
}
\newcommand*{\@bidi@logo@}{%
  \@bidi@logo@hb@xt@columnwidth
    {\hss\LRE{\bfseries Typeset by the \textsf{bidi}
    package\quad\@bidi@logo{bidi-logo.pdf}}}}
\define@key{bidi@pdfencrypt}{userpassword}[]{%
  \def\bidi@pdfencrypt@userpassword{#1}%
}
\define@key{bidi@pdfencrypt}{ownerpassword}[]{%
  \def\bidi@pdfencrypt@ownerpassword{#1}%
}
\define@key{bidi@pdfencrypt}{keylength}[128]{%
  \def\bidi@pdfencrypt@keylength{#1}%
}
\define@key{bidi@pdfencrypt}{permissionflags}[2052]{%
  \def\bidi@pdfencrypt@permissionflags{#1}%
}
\newcommand*{\pdfencryptsetup}{\setkeys{bidi@pdfencrypt}}
\@onlypreamble\pdfencryptsetup
\input{latex-xetex-bidi.def}
\input{loadingorder-xetex-bidi.def}
\define@choicekey{bidi.sty}{RTLdocument}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \@RTLtrue
  \or
    \@RTLfalse
  \fi}
\define@choicekey{bidi.sty}{documentdirection}[\bidi@tempa\bidi@tempb]{righttoleft,lefttoright}{%
  \ifcase\bidi@tempb\relax
    \@RTLtrue
  \or
    \@RTLfalse
  \fi}
\define@choicekey{bidi.sty}{tabledirection}[\bidi@tempa\bidi@tempb]{righttoleft,lefttoright}{%
  \ifcase\bidi@tempb\relax
    \@RTLtabtrue
  \or
    \@RTLtabfalse
  \fi}
\define@choicekey{bidi.sty}{script}[\bidi@tempa\bidi@tempb]{latin,nonlatin}[latin]{%
  \ifcase\bidi@tempb\relax
    \@nonlatinfalse
  \or
    \@nonlatintrue
  \fi}
\define@choicekey{bidi.sty}{rldocument}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \@RTLtrue
  \or
    \@RTLfalse
  \fi}
\define@choicekey{bidi.sty}{footnoterule}[\bidi@tempa\bidi@tempb]{automatic,left,right,split,textwidth}{%
  \ifcase\bidi@tempb\relax
    \autofootnoterule
  \or
    \leftfootnoterule
  \or
    \rightfootnoterule
  \or
    \SplitFootnoteRule
  \or
    \textwidthfootnoterule
  \fi}
\define@choicekey{bidi.sty}{footnotedirection}[\bidi@tempa\bidi@tempb]{righttoleft,lefttoright}{%
  \ifcase\bidi@tempb\relax
    \@RTL@footnotetrue
  \or
    \@RTL@footnotefalse
  \fi}
\define@choicekey{bidi.sty}{debugfootnotedirection}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \footdir@debugtrue
  \or
    \footdir@debugfalse
  \fi}
\define@choicekey{bidi.sty}{extrafootnotefeatures}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \@extrafootnotefeaturestrue
  \or
    \@extrafootnotefeaturesfalse
  \fi}

\define@choicekey{bidi.sty}{DetectColumn}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
  \def\bidi@firstcolumn@status@write{%
         \protected@write\@auxout{}%
              {\string\bidi@column@status
              {1}}}%
  \def\bidi@lastcolumn@status@write{%
         \protected@write\@auxout{}%
              {\string\bidi@column@status{2}}}%
  \or
    \let\bidi@firstcolumn@status@write\relax
    \let\bidi@lastcolumn@status@write\relax
  \fi}

\define@choicekey{bidi.sty}{logo}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \AtBeginDocument{\@bidi@inslogo@}%
  \or
    \let\@bidi@logo@\@empty \let\@bidi@inslogo@\@empty
  \fi}

\define@choicekey{bidi.sty}{pdfinfo}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \@bidi@pdfm@marktrue
  \or
    \@bidi@pdfm@markfalse
  \fi}


\define@choicekey{bidi.sty}{perpagefootnote}[\bidi@tempa\bidi@tempb]{on,off}[on]{%
  \ifcase\bidi@tempb\relax
    \@bidi@perpage@footnotetrue
  \or
    \@bidi@perpage@footnotefalse
  \fi}

\ExecuteOptionsX{%
    DetectColumn=off%
}

\ProcessOptionsX

\pdfencryptsetup{%
  userpassword,%
  ownerpassword,%
  keylength,%
  permissionflags%
}

\if@extrafootnotefeatures
  \input{extrafootnotefeatures-xetex-bidi.def}
\fi
\newcount\bidi@digits
\XeTeXinterchartokenstate=\@ne
\newXeTeXintercharclass\bidi@digits@charclass
\newXeTeXintercharclass\bidi@sepmark@charclass
\XeTeXcharclass `\. \bidi@sepmark@charclass
\XeTeXcharclass `\- \bidi@sepmark@charclass
\bidi@digits=`\0 \loop \XeTeXcharclass \bidi@digits \bidi@digits@charclass \ifnum\bidi@digits<`\9 \advance\bidi@digits \@ne \repeat
\bidi@digits=`\۰ \loop \XeTeXcharclass \bidi@digits \bidi@digits@charclass \ifnum\bidi@digits<`\۹ \advance\bidi@digits \@ne \repeat
\XeTeXinterchartoks \bidi@sepmark@charclass  \bidi@digits@charclass = {\DigitsDotDashInterCharToks}
\newcommand*{\DigitsDotDashInterCharToks}{\if@nonlatin\char"200F \fi}
\bidi@AtEndPreamble{%
  \if@bidi@perpage@footnote
    \RequirePackage{bidi-perpage}%
    \ResetCounterPerPage{footnote}%
  \fi
  \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:%
     docinfo<<%
     \if@bidi@pdfm@mark
       /Creator(\@bidi@pdfcreator)%
       /Producer(\@bidi@pdfproducer)%
     \fi
     /BIDI.Fullbanner(\@bidi@pdfcustomproperties)%
     \if@bidi@csdef{@xepersian@pdfcustomproperties}{%
       /XEPERSIAN.Fullbanner(\@xepersian@pdfcustomproperties)%
     }{}%
      >>%
    }%
}
\endinput
%%
%% End of file `bidi.sty'.