%%
%% This is file `xepersian.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xepersian.dtx  (with options: `xepersian.sty')
%% 
%%   __________________________________
%%   Copyright © 2008-2010 Vafa Khalighi
%% 
%%   License information appended.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\def\xepersianversion{v1.0.4}
\def\xepersianrevision{revision 122}
\def\xepersiandate{2010/03/01}
\ProvidesPackage{xepersian}[\xepersiandate\space \xepersianversion\space <\xepersianrevision>
Persian typesetting in XeLaTeX]
\RequirePackage[RTLdocument]{bidi}
\RequirePackage{fontspec}
\RequirePackage{xepersian-persiancal}
\RequirePackage{xepersian-mathsdigitspec}
\RequirePackage{etoolbox}
\g@addto@macro\document{%
\special{pdf: docinfo <<
/Creator (X∃Persian \xepersianversion\space <\xepersianrevision> Copyright © 2008-2010 Vafa Khalighi)
         >>}}
\gdef\@latex@error#1#2{%
   \GenericError{%
      \space\space\space\@spaces\@spaces\@spaces
   }{%
      XePersian Error: #1%
   }{%
      Oops! either you have done something wrong or it is a xepersian bug. Please first produce a similar file without using XePersian package and then compile it with xelatex, if you got the same error, then please study the Persian translation of “The not so Short Introduction to LaTeX” by MEHDI OMIDALI, otherwise please report the error with a minimal tex file which shows the error to  the Author of XePersian.%
   }{#2}%
}
\gdef\@latexbug{%
  \@latex@error{This may be a XePersian bug}{Please inform the Author of XePersian}}
\def\prq{«}
\def\plq{»}
\newfontscript{Persian}{arab}
\newfontlanguage{Persian}{ARA}
\let\latinnormalfont=\normalfont%
\let\latinrmfamily=\rmfamily%
\let\latinsffamily=\sffamily%
\let\latinttfamily=\ttfamily%
\def\resetlatinfont{\latinnormalfont}
\newcommand*\settextfont[2][]{%
\newfontfamily\persianfont[Script=Persian,Mapping=parsidigits,#1]{#2}}
\def\setpersianfont{%
   \fontencoding{EU1}%
   \let\normalfont=\persianfont%
   \let\rmfamily=\persianfont%
   \let\reset@font\normalfont%
   \normalfont}
\g@addto@macro\document{%
\setpersianfont}
\newcommand*\settxtmathfont[2][]{%
\newfontfamily\TXTmath[Mapping=txt2maths,#1]{#2}
}
\newcommand*\setlatintextfont[2][]{%
  \zf@fontspec{Mapping=tex-text,#1}{#2}%
  \let\rmdefault\zf@family
  \normalfont}
\newcommand*\setlatinsansfont[2][]{%
  \zf@fontspec{Mapping=tex-text,#1}{#2}%
  \let\sfdefault\zf@family
  \normalfont}
\let\setlatinmonofont\setmonofont
\newcommand*\defpersianfont[1]{%
  \@ifnextchar[{\defpersianfont@i#1}{\defpersianfont@i#1[]}}
\def\defpersianfont@i#1[#2]#3{%
  \zf@fontspec{Script=Persian,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\iranicdefault{}
\newcommand\navardefault{}
\newcommand\pookdefault{}
\newcommand\sayehdefault{}
\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{\textiranic}{\iranicfamily}
\DeclareTextFontCommand{\textnavar}{\navarfamily}
\DeclareTextFontCommand{\textpook}{\pookfamily}
\DeclareTextFontCommand{\textsayeh}{\sayehfamily}
\newcommand*\setnavarfont[2][]{%
  \zf@fontspec{Script=Persian,Mapping=parsidigits,#1}{#2}%
  \let\navardefault\zf@family
  \normalfont}
\newcommand*\setpookfont[2][]{%
  \zf@fontspec{Script=Persian,Mapping=parsidigits,#1}{#2}%
  \let\pookdefault\zf@family
  \normalfont}
\newcommand*\setsayehfont[2][]{%
  \zf@fontspec{Script=Persian,Mapping=parsidigits,#1}{#2}%
  \let\sayehdefault\zf@family
  \normalfont}
\newcommand*\setiranicfont[2][]{%
  \zf@fontspec{Script=Persian,Mapping=parsidigits,#1}{#2}%
  \let\iranicdefault\zf@family
  \normalfont}
\def\lr#1{\begingroup\beginL\resetlatinfont#1\endL\endgroup}
\def\rl#1{\begingroup\beginR\setpersianfont#1\endR\endgroup}
\def\latin{\bgroup\LatinAlphs\par\@RTLfalse\@Latintrue\@RTL@footnotefalse\resetlatinfont}
\def\endlatin{\par\egroup}
\def\persian{\bgroup\PersianAlphs\par\@RTLtrue\@RTL@footnotetrue\setpersianfont}
\def\endpersian{\par\egroup}
\def\Latin{\if@RTL\par\LatinAlphs\@RTLfalse\@Latintrue\@RTL@footnotefalse\resetlatinfont\fi}
\def\Persian{\if@RTL\relax\else\par\PersianAlphs\@RTLtrue\@Latinfalse\@RTL@footnotetrue\setpersianfont\fi}
\let\originaltoday=\today
\def\today{\lr{\originaltoday}}
\let\latintoday\today
\def\today{\rl{\persiantoday}}
\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
  \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{\@thehead}%
        \color@endbox
        }%                        %% 22 Feb 87
      \dp\@tempboxa \z@
      \box\@tempboxa
      \vskip \headsep
      \box\@outputbox
      \baselineskip \footskip
      \color@hbox
        \normalcolor
        \hb@xt@\textwidth{\@thefoot}%
      \color@endbox
      }%
    }%
  \global\let\if@newlist\@@if@newlist
  \global \@colht \textheight
  \stepcounter{page}%
  \let\firstmark\botmark
}
\newcommand\twocolumnstableofcontents{%
  \begin{multicols}{2}[\section*{\contentsname}]%
    \small
    \@starttoc{toc}%
  \end{multicols}}
\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 الف\char"200D\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 ه\char"200D\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
\@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{bidi}{\input{footnote-bidi-xepersian.def}}{}
\@ifpackageloaded{breqn}{\input{breqn-xepersian.def}}{}
\@ifpackageloaded{enumerate}{\input{enumerate-xepersian.def}}{}
\@ifpackageloaded{hyperref}{\input{hyperref-xepersian.def}}{}
\@ifpackageloaded{minitoc}{\input{minitoc-xepersian.def}}{}
\@ifpackageloaded{tocloft}{\@ifclassloaded{memoir}{}{\input{tocloft-xepersian.def}}}{}
\@ifclassloaded{article}{\input{article-xepersian.def}}{}
\@ifclassloaded{amsart}{\input{amsart-xepersian.def}}{}
\@ifclassloaded{bidimoderncv}{\input{bidimoderncv-xepersian.def}}{}
\@ifclassloaded{report}{\input{report-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{xepersian-thesis}{\input{xepersian-thesis-xepersian.def}}{}
\@ifclassloaded{amsbook}{\input{amsbook-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{bidibeamer}{\input{bidibeamer-xepersian.def}}{}
\@ifclassloaded{memoir}{\input{memoir-xepersian.def}}{}
\DeclareOption{Kashida}{\input{kashida-xepersian.def}}
\DeclareOption{localise}{\input{localise-xepersian.def}}
\ProcessOptions
%% 
%% Copyright © 2008-2010      by Vafa Khalighi     <vafa@users.berlios.de>
%% 
%% 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 `xepersian.sty'.
