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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
%%
%% This is file `xepersian.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xepersian.dtx (with options: `xepersian.sty')
%%
%% ______________________________________
%% Copyright © 2008–2011 Vafa Khalighi
%%
%% License information appended.
%%
%%
\NeedsTeXFormat{LaTeX2e}
\def\xepersianversion{v1.1.6}
\def\xepersiandate{2011/08/01}
\ProvidesPackage{xepersian}[\xepersiandate\space \xepersianversion\space
Persian typesetting in XeLaTeX]
\RequirePackage{fontspec}
\RequirePackage{xepersian-persiancal}
\RequirePackage{xepersian-mathsdigitspec}
\RequirePackage{etoolbox}
\RequirePackage[RTLdocument]{bidi}
\edef\xepersianinfo{%
xepersian package (Persian for LaTeX over XeTeX)^^J
Description: The package supports Persian^^J
typesetting, using fonts provided in the distribution.^^J
Copyright © 2008–2011 Vafa Khalighi^^J
\xepersianversion, \xepersiandate^^J
License: LaTeX Project Public License, version 1.3c or higher (your choice)^^J
Home: http://bitbucket.org/vafa/xepersian^^J
Location on CTAN: /macros/xetex/latex/xepersian}
\typeout{\xepersianinfo}
\edef\xepersian@everyjob{\the\everyjob}
\everyjob{\xepersian@everyjob\typeout{\xepersianinfo}}
\def\prq{«}
\def\plq{»}
\def\xepersian@cmds@temp#1{%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname xepersian@#1\endcsname\relax
\begingroup
\escapechar=-1 %
\edef\x{\expandafter\meaning\csname#1\endcsname}%
\def\y{#1}%
\def\z##1->{}%
\edef\y{\expandafter\z\meaning\y}%
\expandafter\endgroup
\ifx\x\y
\expandafter\def\csname xepersian@#1\expandafter\endcsname
\expandafter{%
\csname#1\endcsname
}%
\fi
\fi
}%
\xepersian@cmds@temp{shellescape}
\newif\ifwritexviii
\ifnum\xepersian@shellescape=1\relax
\writexviiitrue
\else
\writexviiifalse
\fi
\newfontscript{Parsi}{arab}
\newfontlanguage{Parsi}{FAR}
\newcommand*\settextfont[2][]{%
\newfontfamily\persianfont[Script=Parsi,Language=Parsi,Mapping=parsidigits,#1]{#2}
\let\rmdefault\zf@family
\normalfont
}
\newcommand*\setlatintextfont[2][]{%
\newfontfamily\latinfont[Mapping=tex-text,#1]{#2}
}
\setlatintextfont[ExternalLocation,BoldFont={lmroman10-bold},BoldItalicFont={lmroman10-bolditalic},ItalicFont={lmroman10-italic},SmallCapsFont={lmromancaps10-regular},SlantedFont={lmromanslant10-regular},BoldSlantedFont={lmromanslant10-bold}]{lmroman10-regular}
\let\setlatinsansfont\setsansfont
\let\setlatinmonofont\setmonofont
\newcommand*\defpersianfont[1]{%
\@ifnextchar[{\defpersianfont@i#1}{\defpersianfont@i#1[]}}
\def\defpersianfont@i#1[#2]#3{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#2}{#3}%
\edef\@tempa{%
\noexpand\DeclareRobustCommand\noexpand#1
{\noexpand\fontfamily{\zf@family}\noexpand\selectfont}}%
\@tempa}
\newcommand*\deflatinfont[1]{%
\@ifnextchar[{\deflatinfont@i#1}{\deflatinfont@i#1[]}}
\def\deflatinfont@i#1[#2]#3{%
\zf@fontspec{Mapping=tex-text,#2}{#3}%
\edef\@tempa{%
\noexpand\DeclareRobustCommand\noexpand#1
{\noexpand\fontfamily{\zf@family}\noexpand\selectfont}}%
\@tempa}
\newcommand\persiansfdefault{}
\newcommand\persianttdefault{}
\newcommand\iranicdefault{}
\newcommand\navardefault{}
\newcommand\pookdefault{}
\newcommand\sayehdefault{}
\DeclareRobustCommand\persiansffamily
{\not@math@alphabet\persiansffamily\mathpersiansf
\fontfamily\persiansfdefault\selectfont}
\DeclareRobustCommand\persianttfamily
{\not@math@alphabet\persianttfamily\mathpersiantt
\fontfamily\persianttdefault\selectfont}
\DeclareRobustCommand\iranicfamily
{\not@math@alphabet\iranicfamily\mathiranic
\fontfamily\iranicdefault\selectfont}
\DeclareRobustCommand\navarfamily
{\not@math@alphabet\navarfamily\mathnavar
\fontfamily\navardefault\selectfont}
\DeclareRobustCommand\pookfamily
{\not@math@alphabet\pookfamily\mathpook
\fontfamily\pookdefault\selectfont}
\DeclareRobustCommand\sayehfamily
{\not@math@alphabet\sayehfamily\mathsayeh
\fontfamily\sayehdefault\selectfont}
\DeclareTextFontCommand{\textpersiansf}{\persiansffamily}
\DeclareTextFontCommand{\textpersiantt}{\persianttfamily}
\DeclareTextFontCommand{\textiranic}{\iranicfamily}
\DeclareTextFontCommand{\textnavar}{\navarfamily}
\DeclareTextFontCommand{\textpook}{\pookfamily}
\DeclareTextFontCommand{\textsayeh}{\sayehfamily}
\newcommand*\setpersiansansfont[2][]{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2}%
\let\persiansfdefault\zf@family
\normalfont}
\newcommand*\setpersianmonofont[2][]{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2}%
\let\persianttdefault\zf@family
\normalfont}
\newcommand*\setnavarfont[2][]{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2}%
\let\navardefault\zf@family
\normalfont}
\newcommand*\setpookfont[2][]{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2}%
\let\pookdefault\zf@family
\normalfont}
\newcommand*\setsayehfont[2][]{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2}%
\let\sayehdefault\zf@family
\normalfont}
\newcommand*\setiranicfont[2][]{%
\zf@fontspec{Script=Parsi,Language=Parsi,Mapping=parsidigits,#1}{#2}%
\let\iranicdefault\zf@family
\normalfont}
\def\resetlatinfont{%
\let\normalfont\latinfont%
\latinfont}
\def\setpersianfont{%
\let\normalfont\persianfont%
\persianfont}
\def\lr#1{\LRE{\latinfont#1}}
\def\rl#1{\RLE{\persianfont#1}}
\def\latin{\LTR\LatinAlphs\@Latintrue\@RTL@footnotefalse\resetlatinfont}
\def\endlatin{\endLTR}
\def\persian{\RTL\PersianAlphs\@RTL@footnotetrue\setpersianfont}
\def\endpersian{\endRTL}
\let\originaltoday=\today
\def\today{\lr{\originaltoday}}
\let\latintoday\today
\def\today{\rl{\persiantoday}}
\def \@LTRmarginparreset {%
\reset@font
\latinfont
\normalsize
\@minipagetrue
\everypar{\@minipagefalse\everypar{}\beginL}%
}
\DeclareRobustCommand\Latincite{%
\@ifnextchar [{\@tempswatrue\@Latincitex}{\@tempswafalse\@Latincitex[]}}
\def\@Latincitex[#1]#2{\leavevmode
\let\@citea\@empty
\@cite{\lr{\@for\@citeb:=#2\do
{\@citea\def\@citea{,\penalty\@m\ }%
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
\@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\@cite@ofmt{\csname b@\@citeb\endcsname}}}}}{#1}}
\def\@outputpage{%
\begingroup % the \endgroup is put in by \aftergroup
\let \protect \noexpand
\@resetactivechars
\global\let\@@if@newlist\if@newlist
\global\@newlistfalse
\@parboxrestore
\shipout \vbox{%
\set@typeset@protect
\aftergroup \endgroup
\aftergroup \set@typeset@protect
% correct? or just restore by ending
% the group?
\if@specialpage
\global\@specialpagefalse\@nameuse{ps@\@specialstyle}%
\fi
\if@twoside
\ifodd\count\z@ \let\@thehead\@oddhead \let\@thefoot\@oddfoot
\let\@themargin\oddsidemargin
\else \let\@thehead\@evenhead
\let\@thefoot\@evenfoot \let\@themargin\evensidemargin
\fi
\ifx\@thehead\@empty \let\@thehead\hfil \fi
\ifx\@thefoot\@empty \let\@thefoot\hfil \fi
\else %% not @twoside
\ifx\@oddhead\@empty \let\@thehead\hfil \fi
\ifx\@oddfoot\@empty \let\@thefoot\hfil \fi
\fi
\reset@font
\normalsize
\if@RTLmain\setpersianfont\else\resetlatinfont\fi
\normalsfcodes
\let\label\@gobble
\let\index\@gobble
\let\glossary\@gobble
\baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
\@begindvi
\vskip \topmargin
\moveright\@themargin \vbox {%
\setbox\@tempboxa \vbox to\headheight{%
\vfil
\color@hbox
\normalcolor
\hb@xt@\textwidth{\if@RTLmain\beginR\fi\@thehead\if@RTLmain\endR\fi}%
\color@endbox
}% %% 22 Feb 87
\dp\@tempboxa \z@
\box\@tempboxa
\vskip \headsep
\box\@outputbox
\baselineskip \footskip
\color@hbox
\normalcolor
\hb@xt@\textwidth{\if@RTLmain\beginR\fi\@thefoot\if@RTLmain\endR\fi}%
\color@endbox
}%
}%
\global\let\if@newlist\@@if@newlist
\global \@colht \textheight
\stepcounter{page}%
\let\firstmark\botmark
}
\newcommand\twocolumnstableofcontents{%
\@ifpackageloaded{multicol}{%
\begin{multicols}{2}[\section*{\contentsname}]%
\small
\@starttoc{toc}%
\end{multicols}}
{\PackageError{xepersian}{Oops! you should load multicol package before xepersian package for being able to use this command}{}}}
\def\XePersian{\leavevmode$\smash{\hbox{X\lower.5ex
\hbox{\kern-.125em\reflect{E}}Persian}}$}
\def\figurename{\if@RTL شکل\else Figure\fi}
\def\tablename{\if@RTL جدول\else Table\fi}
\def\contentsname{\if@RTL فهرست مطالب\else Contents\fi}
\def\listfigurename{\if@RTL لیست تصاویر\else List of Figures\fi}
\def\listtablename{\if@RTL لیست جداول\else List of Tables\fi}
\def\appendixname{\if@RTL پیوست\else Appendix\fi}
\def\indexname{\if@RTL نمایه\else Index\fi}
\def\refname{\if@RTL مراجع\else References\fi}
\def\abstractname{\if@RTL چکیده\else Abstract\fi}
\def\partname{\if@RTL بخش\else Part\fi}
\def\datename{\if@RTL تاریخ:\else Date:\fi}
\def\@@and{\if@RTL و\else and\fi}
\def\bibname{\if@RTL کتابنامه\else Bibliography\fi}
\def\chaptername{\if@RTL فصل\else Chapter\fi}
\def\ccname{\if@RTL رونوشت\else cc\fi}
\def\enclname{\if@RTL پیوست\else encl\fi}
\def\pagename{\if@RTL صفحه\else Page\fi}
\def\headtoname{\if@RTL به\else To\fi}
\def\proofname{\if@RTL اثبات\else Proof\fi}
\def\@harfi#1{\ifcase#1\or آ\or ب\or پ\or ت\or ث\or
ج\or چ\or ح\or خ\or د\or ذ\or ر\or ز\or ژ\or س\or ش\or ص\or ض\or ط\or ظ\or ع\or غ\or
ف\or ق\or ک\or گ\or ل\or م\or ن\or و\or ه\or ی\else\@ctrerr\fi}
\def\harfi#1{\expandafter\@harfi\csname c@#1\endcsname}
\def\@adadi#1{\ifcase#1 \or یک\or دو\or سه\or چهار\or پنج\or شش\or هفت\or هشت\or نه\or ده\or یازده\or دوازده\or سیزده\or چهارده\or پانزده\or شانزده\or هفده\or هجده\or نوزده\or بیست\else\@ctrerr\fi}
\def\adadi#1{\expandafter\@adadi\csname c@#1\endcsname}
\def\@tartibi#1{\ifcase#1 \or اول \or دوم \or سوم \or چهارم \or پنجم \or ششم \or هفتم \or هشتم \or نهم \or دهم \or یازدهم \or دوازدهم \or سیزدهم \or چهاردهم \or پانزدهم \or شانزدهم \or هفدهم \or هجدهم \or نوزدهم \or بیستم\else\@ctrerr\fi}
\def\tartibi#1{\expandafter\@tartibi\csname c@#1\endcsname}
\providecommand*{\xpg@warning}[1]{%
\PackageWarning{XePersian}%
{#1}}
\ifcsdef{abjad}{}{%
\def\abjad#1{%
\ifnum#1>1999 \xpg@warning{Illegal value (#1) for abjad numeral} {#1}
\else
\ifnum#1<\z@\space\xpg@warning{Illegal value (#1) for abjad numeral}%
\else
\ifnum#1<10\expandafter\abj@num@i\number#1%
\else
\ifnum#1<100\expandafter\abj@num@ii\number#1%
\else
\ifnum#1<\@m\expandafter\abj@num@iii\number#1%
\else
\ifnum#1<\@M\expandafter\abj@num@iv\number#1%since #1<2000, we must have 1000
\fi
\fi
\fi
\fi
\fi
\fi
}
\def\abjad@zero{}
\def\abj@num@i#1{%
\ifcase#1\or آ\or ب\or ج\or د%
\or ه\or و\or ز\or ح\or ط\fi
\ifnum#1=\z@\abjad@zero\fi}
\def\abj@num@ii#1{%
\ifcase#1\or ی\or ک\or ل\or م\or ن%
\or س\or ع\or ف\or ص\fi
\ifnum#1=\z@\fi\abj@num@i}
\def\abj@num@iii#1{%
\ifcase#1\or ق\or ر\or ش\or ت\or ث%
\or خ\or ذ\or ض\or ظ\fi
\ifnum#1=\z@\fi\abj@num@ii}
\def\abj@num@iv#1{%
\ifcase#1\or غ\fi
\ifnum#1=\z@\fi\abj@num@iii}
}
\let\@latinalph\@alph%
\let\@latinAlph\@Alph%
\def\PersianAlphs{%
\let\@alph\abjad%
\let\@Alph\abjad%
}
\def\LatinAlphs{%
\let\@alph\@latinalph%
\let\@Alph\@latinAlph%
}
\PersianAlphs
\@ifdefinitionfileloaded{loadingorder-bidi}{\input{loadingorder-bidi-xepersian.def}}{}
\@ifpackageloaded{listings}{\input{listings-xepersian.def}}{}
\@ifpackageloaded{algorithmic}{\input{algorithmic-xepersian.def}}{}
\@ifpackageloaded{algorithm}{\input{algorithm-xepersian.def}}{}
\@ifpackageloaded{backref}{\input{backref-xepersian.def}}{}
\@ifpackageloaded{flowfram}{\input{flowfram-xepersian.def}}{}
\@ifpackageloaded{bidi}{\input{footnote-bidi-xepersian.def}}{}
\@ifpackageloaded{bidituftesidenote}{\input{bidituftesidenote-xepersian.def}}{}
\@ifpackageloaded{bidicode}{\input{bidicode-xepersian.def}}{}
\@ifpackageloaded{breqn}{\input{breqn-xepersian.def}}{}
\@ifpackageloaded{enumerate}{\input{enumerate-xepersian.def}}{}
\@ifpackageloaded{empheq}{\input{empheq-xepersian.def}}{}
\@ifpackageloaded{hyperref}{\input{hyperref-xepersian.def}}{}
\@ifpackageloaded{minitoc}{\input{minitoc-xepersian.def}}{}
\@ifpackageloaded{multicol}{\input{multicol-xepersian.def}}{}
\@ifpackageloaded{natbib}{\input{natbib-xepersian.def}}{}
\@ifpackageloaded{tocloft}{\@ifclassloaded{memoir}{}{\input{tocloft-xepersian.def}}}{}
\@ifclassloaded{article}{\input{article-xepersian.def}}{}
\@ifclassloaded{extarticle}{\input{extarticle-xepersian.def}}{}
\@ifclassloaded{artikel1}{\input{artikel1-xepersian.def}}{}
\@ifclassloaded{artikel2}{\input{artikel2-xepersian.def}}{}
\@ifclassloaded{artikel3}{\input{artikel3-xepersian.def}}{}
\@ifclassloaded{amsart}{\input{amsart-xepersian.def}}{}
\@ifclassloaded{bidimoderncv}{\input{bidimoderncv-xepersian.def}}{}
\@ifclassloaded{report}{\input{report-xepersian.def}}{}
\@ifclassloaded{extreport}{\input{extreport-xepersian.def}}{}
\@ifclassloaded{rapport1}{\input{rapport1-xepersian.def}}{}
\@ifclassloaded{rapport3}{\input{rapport3-xepersian.def}}{}
\@ifclassloaded{scrartcl}{\input{scrartcl-xepersian.def}}{}
\@ifclassloaded{scrbook}{\input{scrbook-xepersian.def}}{}
\@ifclassloaded{scrreprt}{\input{scrreprt-xepersian.def}}{}
\@ifclassloaded{amsbook}{\input{amsbook-xepersian.def}}{}
\@ifclassloaded{boek3}{\input{boek3-xepersian.def}}{}
\@ifclassloaded{boek}{\input{boek-xepersian.def}}{}
\@ifclassloaded{bookest}{\input{bookest-xepersian.def}}{}
\@ifclassloaded{extbook}{\input{extbook-xepersian.def}}{}
\@ifclassloaded{book}{\input{book-xepersian.def}}{}
\@ifclassloaded{refrep}{\input{refrep-xepersian.def}}{}
\@ifclassloaded{memoir}{\input{memoir-xepersian.def}}{}
\DeclareOption{Kashida}{\input{kashida-xepersian.def}}
\DeclareOption{localise}{\input{localise-xepersian.def}}
\DeclareOption{extrafootnotefeatures}{%
\input{extrafootnotefeatures.def}%
\input{extrafootnotefeatures-xepersian.def}%
}
\DeclareOption{quickindex}{%
\ifwritexviii%
\@ifclassloaded{memoir}{\PackageError{xepersian}{This feature does not yet work with the memoir class}{}}{%
\renewcommand\printindex{\newpage%
\immediate\closeout\@indexfile
\immediate\write18{xindy -L persian -C utf8 -M texindy \jobname.idx}
\@input@{\jobname.ind}}}%
\else
\PackageError{xepersian}{“shell escape” (or “write18”) is not enabled. You need to run “xelatex --shell-escape” on your TeX document for this feature to work}{}
\fi}
\ExecuteOptions{localise}
\ProcessOptions
%%
%% Copyright © 2008–2011 Vafa Khalighi <vafa018@gmail.com>
%%
%% 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.
%%
%%
%%
%%
%% End of file `xepersian.sty'.
|