%%
%% This is file `luapersian.sty',
%% generated with the docstrip utility.
%% 
%%   ______________________________________
%%   Copyright © 2011  Vafa Khalighi
%% 
%%   License information appended.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\def\luapersianversion{v0.1}
\def\luapersiandate{2011/08/01}
\ProvidesPackage{luapersian}[\luapersiandate\space \luapersianversion\space
Persian typesetting in LuaLaTeX]
\RequirePackage{iftex}
\RequireLuaTeX
\def\@tagsextension{clo}
\def\@iftagsloaded{\@ifl@aded\@tagsextension}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% start of bidi related macros
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\if@Latin
\newif\if@RTL@footnote
\newif\if@RTL
\newif\if@RTLtab
\newif\if@RTLbibitems
\newif\if@LTRbibitems
\@RTLtrue
\newif\if@RTLmain
\@RTLmaintrue
\directlua { tex.enableprimitives('',{'pagedir','bodydir','pardir','textdir'}) }
\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT
\def\@arabic#1{\bgroup\textdir TLT\number #1\egroup}  %% changed 29 Apr 86
\def\@roman#1{\bgroup\textdir TLT\romannumeral #1\egroup}
\def\@Roman#1{\bgroup\textdir TLT\expandafter\@slowromancap\romannumeral #1@\egroup}
\def\@eqnnum{{\normalfont \normalcolor (\if@RTL\bgroup\textdir TRT\fi\theequation\if@RTL\egroup\fi)}}
\everydisplay\expandafter{\the\everydisplay\predisplaydirection=0 }
\RequirePackage{pdftexcmds}
\RequirePackage{fontspec}
\RequirePackage{luapersian-persiancal}
\RequirePackage{luapersian-mathsdigitspec}
\RequirePackage{etoolbox}
\let\n@xt=\
\def\LRE{\protect\pLRE}%
\def\pLRE{\protect\afterassignment\moreLRE \let\n@xt= }
\def\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}
\def\moreLRE{\bracetext \textdir TLT}
\def\moreRLE{\bracetext \textdir TRT}
\def\LTR{\par\@RTLfalse\@RTL@footnotefalse\bodydir TLT\pardir TLT\textdir TLT\hsize\linewidth\parshape\z@}
\def\endLTR{\par}
\def\RTL{\par\@RTLtrue\@RTL@footnotetrue\bodydir TRT\pardir TRT\textdir TRT\hsize\linewidth\parshape\z@}
\def\endRTL{\par}
\protected\def\hboxR{\hbox\bgroup
 \everyhbox{%
  \aftergroup\egroup
  \everyhbox{}%
  \bgroup
  \aftergroup\egroup
 }\hbox dir TRT}
\protected\def\hboxL{\hbox\bgroup
 \everyhbox{%
  \aftergroup\egroup
  \everyhbox{}%
  \bgroup
  \aftergroup\egroup
 }\hbox dir TLT}
\protected\def\vboxR{\vbox\bgroup
 \everyvbox{%
  \aftergroup\egroup
  \everyvbox{}%
  \bgroup
  \aftergroup\egroup
 }\vbox dir TRT}
\protected\def\vboxL{\vbox\bgroup
 \everyvbox{%
  \aftergroup\egroup
  \everyvbox{}%
  \bgroup
  \aftergroup\egroup
 }\vbox dir TLT}
\def\list#1#2{%
  \ifnum \@listdepth >5\relax
    \@toodeep
  \else
    \global\advance\@listdepth\@ne
  \fi
  \rightmargin\z@
  \listparindent\z@
  \itemindent\z@
  \csname @list\romannumeral\the\@listdepth\endcsname
  \def\@itemlabel{#1}%
  \let\makelabel\@mklab
  \@nmbrlistfalse
  #2\relax
  \@trivlist
  \parskip\parsep
  \parindent\listparindent
  \advance\linewidth -\rightmargin
  \advance\linewidth -\leftmargin
  \if@RTL
  \advance\@totalleftmargin \leftmargin
  \else
  \advance\@totalleftmargin \rightmargin
  \fi
  \parshape \@ne \@totalleftmargin \linewidth
  \ignorespaces}
\def\setRTLbibitems{\@RTLbibitemstrue\@LTRbibitemsfalse}
\def\setLTRbibitems{\@LTRbibitemstrue\@RTLbibitemsfalse}
\def\setdefaultbibitems{\@RTLbibitemsfalse\@LTRbibitemsfalse}
\newenvironment{RTLitems}[1][\labelsep]
                 {\par\bodydir TRT\pardir TRT\textdir TRT
                  \rightskip\labelwidth
                  \advance\rightskip #1
                  \advance\leftskip -\leftmargin
                  \ignorespaces}{\endtrivlist}
\newenvironment{LTRitems}[1][\labelsep]
                 {\par\bodydir TLT\pardir TLT\textdir TLT
                  \leftskip\labelwidth
                  \advance\leftskip #1
                  \advance\rightskip -\leftmargin
                  \ignorespaces}{\endtrivlist}
\newenvironment{RTLbibitems}[1][\labelsep]
                 {\par\bodydir TRT\pardir TRT\textdir TRT
                  \rightskip\labelwidth
                  \advance\rightskip #1
                  \advance\leftskip -\leftmargin
                  \ignorespaces}{\endtrivlist}
\newenvironment{LTRbibitems}[1][\labelsep]
                 {\par\bodydir TLT\pardir TLT\textdir TLT
                  \leftskip\labelwidth
                  \advance\leftskip #1
                  \advance\rightskip -\leftmargin
                  \ignorespaces}{\endtrivlist}
\newcommand{\bidiraggedright}{\if@RTL\raggedleft\else\raggedright\fi}
\newcommand{\bidiraggedleft}{\if@RTL\raggedright\else\raggedleft\fi}
\def\leftline#1{%
\if@RTL\@@line{\hss#1}
\else\@@line{#1\hss}\fi}
\def\rightline#1{%
\if@RTL\@@line{#1\hss}
\else\@@line{\hss#1}\fi}
\def\bidirlap#1{\hb@xt@\z@{\if@RTL\hss\fi#1\if@RTL\else\hss\fi}}
\def\bidillap#1{\hb@xt@\z@{\if@RTL\else\hss\fi#1\if@RTL\hss\fi}}
\def\flushleft{\trivlist \bidiraggedright\item\relax}
\def\flushright{\trivlist \bidiraggedleft\item\relax}
\def\LTRmarginpar{%
  \ifhmode
    \@bsphack
    \@floatpenalty -\@Mii
  \else
    \@floatpenalty-\@Miii
  \fi
  \ifinner
    \@parmoderr
    \@floatpenalty\z@
  \else
    \@next\@currbox\@freelist{}{}%
    \@next\@marbox\@freelist{\global\count\@marbox\m@ne}%
       {\@floatpenalty\z@
        \@fltovf\def\@currbox{\@tempboxa}\def\@marbox{\@tempboxa}}%
  \fi
  \@ifnextchar [\@LTRxmpar\@LTRympar}
\long\def\@LTRxmpar[#1]#2{%
  \@LTRsavemarbox\@marbox{#1}%
  \@LTRsavemarbox\@currbox{#2}%
  \@xympar}
\long\def\@LTRympar#1{%
  \@LTRsavemarbox\@marbox{#1}%
  \global\setbox\@currbox\copy\@marbox
  \@xympar}
\long\def \@LTRsavemarbox #1#2{%
  \global\setbox #1%
    \color@vbox
      \vtop dir TLT{%
        \hsize\marginparwidth
        \@parboxrestore
        \@LTRmarginparreset
        #2%
        \@minipagefalse
        \outer@nobreak
        }%
    \color@endbox
}
\def \@LTRmarginparreset {%
        \reset@font
        \latinfont
        \normalsize
        \@minipagetrue
        \everypar{\@minipagefalse\everypar{}}%
}
\def\RTLmarginpar{%
  \ifhmode
    \@bsphack
    \@floatpenalty -\@Mii
  \else
    \@floatpenalty-\@Miii
  \fi
  \ifinner
    \@parmoderr
    \@floatpenalty\z@
  \else
    \@next\@currbox\@freelist{}{}%
    \@next\@marbox\@freelist{\global\count\@marbox\m@ne}%
       {\@floatpenalty\z@
        \@fltovf\def\@currbox{\@tempboxa}\def\@marbox{\@tempboxa}}%
  \fi
  \@ifnextchar [\@RTLxmpar\@RTLympar}
\long\def\@RTLxmpar[#1]#2{%
  \@RTLsavemarbox\@marbox{#1}%
  \@RTLsavemarbox\@currbox{#2}%
  \@xympar}
\long\def\@RTLympar#1{%
  \@RTLsavemarbox\@marbox{#1}%
  \global\setbox\@currbox\copy\@marbox
  \@xympar}
\long\def \@RTLsavemarbox #1#2{%
  \global\setbox #1%
    \color@vbox
      \vtop dir TRT{%
        \hsize\marginparwidth
        \@parboxrestore
        \@RTLmarginparreset
        #2%
        \@minipagefalse
        \outer@nobreak
        }%
    \color@endbox
}
\def \@RTLmarginparreset {%
        \reset@font
        \normalsize
        \@minipagetrue
        \everypar{\@minipagefalse\everypar{}}%
}
\def\@addmarginpar{\@next\@marbox\@currlist{\@cons\@freelist\@marbox
    \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
    \if@twocolumn
        \if@firstcolumn \@tempcnta\m@ne \fi
    \else
      \if@mparswitch
         \ifodd\c@page \else\@tempcnta\m@ne \fi
      \fi
      \if@reversemargin \@tempcnta -\@tempcnta \fi
    \fi
    \ifnum\@tempcnta <\z@  \global\setbox\@marbox\box\@currbox \fi
    \@tempdima\@mparbottom
    \advance\@tempdima -\@pageht
    \advance\@tempdima\ht\@marbox
    \ifdim\@tempdima >\z@
      \@latex@warning@no@line {Marginpar on page \thepage\space moved}%
    \else
      \@tempdima\z@
    \fi
    \global\@mparbottom\@pageht
    \global\advance\@mparbottom\@tempdima
    \global\advance\@mparbottom\dp\@marbox
    \global\advance\@mparbottom\marginparpush
    \advance\@tempdima -\ht\@marbox
    \global\setbox \@marbox
                   \vbox {\vskip \@tempdima
                          \box \@marbox}%
    \global \ht\@marbox \z@
    \global \dp\@marbox \z@
    \kern -\@pagedp
    \nointerlineskip
    \if@RTL\if@LTRmarginpar
    \hbox dir TLT to\columnwidth
    \else
    \hbox dir TRT to\columnwidth
    \fi
    \else
    \if@RTLmarginpar
    \hbox dir TRT to\columnwidth
    \else
    \hbox dir TLT to\columnwidth
    \fi\fi
      {\ifnum \@tempcnta >\z@
          \hskip\columnwidth \hskip\marginparsep
       \else
          \hskip -\marginparsep \hskip -\marginparwidth
       \fi
       \box\@marbox \hss}%
    \nointerlineskip
    \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}}
\long\def\@ympar#1{%
  \@savemarbox\@marbox{\if@RTL\if@LTRmarginpar\pardir TLT\textdir TLT\else\pardir TRT\textdir TRT\fi\else\if@RTLmarginpar\pardir TRT\textdir TRT\else\pardir TLT\textdir TLT\fi\fi#1}%
  \global\setbox\@currbox\copy\@marbox
  \@xympar}
\def\setRTLmarginpar{\@RTLmarginpartrue\@LTRmarginparfalse}
\def\setLTRmarginpar{\@LTRmarginpartrue\@RTLmarginparfalse}
\def\setdefaultmarginpar{\@RTLmarginparfalse\@LTRmarginparfalse}
\def\@stopline{\unskip\@stopfield\if@rjfield \global\@rjfieldfalse
   \@tempdima\@totalleftmargin \advance\@tempdima\linewidth
\if@RTL\hbox dir TRT to\@tempdima\else
\hbox dir TLT to\@tempdima\fi{\@itemfudge\hskip\dimen\@curtabmar
   \box\@curline\hfil\box\@curfield}\else\@addfield
   \if@RTL\hbox dir TRT to\linewidth\else\hbox dir TLT to\linewidth\fi{\@itemfudge
   \hskip\dimen\@curtabmar\box\@curline\hfil}%
\fi}
\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
          \if@RTLmain\hbox dir TRT to\textwidth\else\hbox dir TLT to\textwidth\fi{\@thehead}%
        \color@endbox
        }%                        %% 22 Feb 87
      \dp\@tempboxa \z@
      \box\@tempboxa
      \vskip \headsep
      \box\@outputbox
      \baselineskip \footskip
      \color@hbox
        \normalcolor
        \if@RTLmain\hbox dir TRT to\textwidth\else\hbox dir TLT to\textwidth\fi{\@thefoot}%
      \color@endbox
      }%
    }%
  \global\let\if@newlist\@@if@newlist
  \global \@colht \textheight
  \stepcounter{page}%
  \let\firstmark\botmark
}
\global\@RTLtabfalse
\def\@tabular{\if@RTL\@RTLtabtrue\fi
   \leavevmode \hbox \bgroup 
   $\let\@acol\@tabacol
   \let\@classz\@tabclassz
   \let\@classiv\@tabclassiv \let\\\@tabularcr\@tabarray}
\def\endtabular{\crcr\egroup
                 \egroup $\egroup
                 \@RTLtabfalse}
\expandafter \let \csname endtabular*\endcsname = \endtabular
\def\@array[#1]#2{%
  \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
  \bgroup
  \setbox\@arstrutbox\hbox{%
    \vrule \@height\arraystretch\ht\strutbox
           \@depth\arraystretch \dp\strutbox
           \@width\z@}%
  \@mkpream{#2}%
  \edef\@preamble{%
    \ialign \noexpand\@halignto
      \bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
  \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
  \let\tabularnewline\\%
    \let\par\@empty
    \let\@sharp##%
    \set@typeset@protect
    \lineskip\z@skip\baselineskip\z@skip
    \ifhmode \@preamerr\z@ \@@par\fi
  \if@RTLtab\textdir TRT\fi
    \@preamble}
\def\array{\let\@acol\@arrayacol \let\@classz\@arrayclassz
 \let\@classiv\@arrayclassiv
 \let\\\@arraycr\let\@halignto\@empty\@RTLtabfalse\@tabarray}
\def\@testpach#1{\@chclass \ifnum \@lastchclass=\tw@ 4 \else
    \ifnum \@lastchclass=3 5 \else
     \z@ \if #1c\@chnum \z@ \else
                              \if \if@RTLtab#1r\else#1l\fi\@chnum \@ne \else
                              \if \if@RTLtab#1l\else#1r\fi\@chnum \tw@ \else
          \@chclass \if #1|\@ne \else
                    \if #1@\tw@ \else
                    \if #1p3 \else \z@ \@preamerr 0\fi
  \fi  \fi  \fi  \fi  \fi  \fi
\fi}
\def\RTL@outputdblcol{%
  \if@firstcolumn
    \global \@firstcolumnfalse
    \global \setbox\@leftcolumn \box\@outputbox
  \else
    \global \@firstcolumntrue
    \setbox\@outputbox \vbox dir TRT{%
                         \hb@xt@\textwidth {%
                           \hb@xt@\columnwidth {%
                             \box\@leftcolumn \hss}%
                           \hfil
                           {\normalcolor\vrule \@width\columnseprule}%
                           \hfil
                           \hb@xt@\columnwidth {%
                             \box\@outputbox \hss}%
                                             }%
                              }%
    \@combinedblfloats
    \@outputpage
    \begingroup
      \@dblfloatplacement
      \@startdblcolumn
      \@whilesw\if@fcolmade \fi
        {\@outputpage
         \@startdblcolumn}%
    \endgroup
  \fi
}
\def\LTR@outputdblcol{%
  \if@firstcolumn
    \global \@firstcolumnfalse
    \global \setbox\@leftcolumn \box\@outputbox
  \else
    \global \@firstcolumntrue
    \setbox\@outputbox \vbox dir TLT {%
                         \hb@xt@\textwidth {%
                           \hb@xt@\columnwidth {%
                             \box\@leftcolumn \hss}%
                           \hfil
                           {\normalcolor\vrule \@width\columnseprule}%
                           \hfil
                           \hb@xt@\columnwidth {%
                             \box\@outputbox \hss}%
                                             }%
                              }%
    \@combinedblfloats
    \@outputpage
    \begingroup
      \@dblfloatplacement
      \@startdblcolumn
      \@whilesw\if@fcolmade \fi
        {\@outputpage
         \@startdblcolumn}%
    \endgroup
  \fi
}
\renewcommand{\@outputdblcol}{\if@RTLmain\RTL@outputdblcol\else\LTR@outputdblcol\fi}
\newcommand{\RTLdblcol}{\renewcommand{\@outputdblcol}{\RTL@outputdblcol}}
\newcommand{\LTRdblcol}{\renewcommand{\@outputdblcol}{\LTR@outputdblcol}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% end of bidi related macros
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\edef\luapersianinfo{%
luapersian package (Persian for LaTeX over LuaTeX)^^J
Description: The package supports Persian typesetting^^J
Copyright © 2011 Vafa Khalighi^^J
\luapersianversion, \luapersiandate^^J
License: LaTeX Project Public License, version 1.3c or higher (your choice)^^J
Home: http://bitbucket.org/vafa/luapersian^^J
Location on CTAN: /macros/luatex/latex/luapersian}
\typeout{\luapersianinfo}
\edef\luapersian@everyjob{\the\everyjob}
\everyjob{\luapersian@everyjob\typeout{\luapersianinfo}}
\def\prq{«}
\def\plq{»}
\newif\ifwritexviii
\ifnum\pdf@shellescape=1\relax
  \writexviiitrue
\else
\writexviiifalse
\fi
\newfontscript{Parsi}{arab}
\newfontlanguage{Parsi}{FAR}
\aliasfontfeatureoption{Numbers}{Arabic}{Parsi}
\newcommand*\settextfont[2][]{%
\newfontfamily\persianfont[Script=Parsi,Numbers=Parsi,Language=Parsi,#1]{#2}
\let\rmdefault\zf@family
  \normalfont
}
\newcommand*\setlatintextfont[2][]{%
\newfontfamily\latinfont[Ligatures=TeX,#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,Numbers=Parsi,Language=Parsi,#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{Ligatures=TeX,#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,Numbers=Parsi,Language=Parsi,#1}{#2}%
  \let\persiansfdefault\zf@family
  \normalfont}
\newcommand*\setpersianmonofont[2][]{%
  \zf@fontspec{Script=Parsi,Numbers=Parsi,Language=Parsi,#1}{#2}%
  \let\persianttdefault\zf@family
  \normalfont}
\newcommand*\setnavarfont[2][]{%
  \zf@fontspec{Script=Parsi,Numbers=Parsi,Language=Parsi,#1}{#2}%
  \let\navardefault\zf@family
  \normalfont}
\newcommand*\setpookfont[2][]{%
  \zf@fontspec{Script=Parsi,Numbers=Parsi,Language=Parsi,#1}{#2}%
  \let\pookdefault\zf@family
  \normalfont}
\newcommand*\setsayehfont[2][]{%
  \zf@fontspec{Script=Parsi,Numbers=Parsi,Language=Parsi,#1}{#2}%
  \let\sayehdefault\zf@family
  \normalfont}
\newcommand*\setiranicfont[2][]{%
  \zf@fontspec{Script=Parsi,Numbers=Parsi,Language=Parsi,#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}}
\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}}
\newcommand\twocolumnstableofcontents{%
\@ifpackageloaded{multicol}{%
  \begin{multicols}{2}[\section*{\contentsname}]%
    \small
    \@starttoc{toc}%
  \end{multicols}}
{\PackageError{luapersian}{Oops! you should load multicol package before luapersian package for being able to use this command}{}}}
\def\LuaPersian{\textsf{LuaPersian}}
\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*{\lpg@warning}[1]{%
   \PackageWarning{LuaPersian}%
   {#1}}
\ifcsdef{abjad}{}{%
\def\abjad#1{%
\ifnum#1>1999 \lpg@warning{Illegal value (#1) for abjad numeral} {#1}
\else
  \ifnum#1<\z@\space\lpg@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
\@ifpackageloaded{mathtools}{\RequirePackage{graphicx}}{}
\@ifpackageloaded{sidecap}{\RequirePackage{ragged2e}}{}
\RequirePackage{luapersian-footnote}
\RequirePackage{loadingorder-luapersian}
\@ifclassloaded{amsart}{\input{amsart-luapersian.def}}{}
\@ifclassloaded{amsbook}{\input{amsbook-luapersian.def}}{}
\@ifclassloaded{article}{\input{article-luapersian.def}}{}
\@ifclassloaded{artikel1}{\input{artikel1-luapersian.def}}{}
\@ifclassloaded{artikel2}{\input{artikel2-luapersian.def}}{}
\@ifclassloaded{artikel3}{\input{artikel3-luapersian.def}}{}
\@ifclassloaded{boek3}{\input{boek3-luapersian.def}}{}
\@ifclassloaded{boek}{\input{boek-luapersian.def}}{}
\@ifclassloaded{book}{\input{book-luapersian.def}}{}
\@ifclassloaded{bookest}{\input{bookest-luapersian.def}}{}
\@ifclassloaded{extarticle}{\input{extarticle-luapersian.def}}{}
\@ifclassloaded{extbook}{\input{extbook-luapersian.def}}{}
\@ifclassloaded{extletter}{\input{extletter-luapersian.def}}{}
\@ifclassloaded{extreport}{\input{extreport-luapersian.def}}{}
\@ifclassloaded{letter}{\input{letter-luapersian.def}}{}
\@ifclassloaded{memoir}{\input{memoir-luapersian.def}}{}
\@ifclassloaded{rapport1}{\input{rapport1-luapersian.def}}{}
\@ifclassloaded{rapport3}{\input{rapport3-luapersian.def}}{}
\@ifclassloaded{refrep}{\input{refrep-luapersian.def}}{}
\@ifclassloaded{report}{\input{report-luapersian.def}}{}
\@ifclassloaded{scrartcl}{\input{scrartcl-luapersian.def}}{}
\@ifclassloaded{scrbook}{\input{scrbook-luapersian.def}}{}
\@ifclassloaded{scrreprt}{\input{scrreprt-luapersian.def}}{}


\@iftagsloaded{leqno}{\input{leqno-luapersian.def}}{}
\@iftagsloaded{fleqn}{\input{fleqn-luapersian.def}}{}


\@ifpackageloaded{algorithmic}{\input{algorithmic-luapersian.def}}{}
\@ifpackageloaded{algorithm}{\input{algorithm-luapersian.def}}{}
\@ifpackageloaded{amstext}{\input{amstext-luapersian.def}}{}
\@ifpackageloaded{amsmath}{\input{amsmath-luapersian.def}}{}
\@ifpackageloaded{array}{\input{array-luapersian.def}}{}
\@ifpackageloaded{arydshln}{\input{arydshln-luapersian.def}}{}
\@ifpackageloaded{backref}{\input{backref-luapersian.def}}{}
\@ifpackageloaded{breqn}{\input{breqn-luapersian.def}}{}
\@ifpackageloaded{enumerate}{\input{enumerate-luapersian.def}}{}
\@ifpackageloaded{fancyhdr}{\input{fancyhdr-luapersian.def}}{}
\@ifpackageloaded{flowfram}{\input{flowfram-luapersian.def}}{}
\@ifpackageloaded{hvfloat}{\input{hvfloat-luapersian.def}}{}
\@ifpackageloaded{hyperref}{\input{hyperref-luapersian.def}}{}
\@ifpackageloaded{listings}{\input{listings-luapersian.def}}{}
\@ifpackageloaded{minitoc}{\input{minitoc-luapersian.def}}{}
\@ifpackageloaded{natbib}{\input{natbib-luapersian.def}}{}
\@ifpackageloaded{pgf}{\input{pgf-luapersian.def}}{}
\@ifpackageloaded{ragged2e}{\input{ragged2e-luapersian.def}}{}
\@ifpackageloaded{sidecap}{\input{sidecap-luapersian.def}}{}
\@ifpackageloaded{stabular}{\input{stabular-luapersian.def}}{}
\@ifpackageloaded{tabls}{\input{tabls-luapersian.def}}{}
\@ifpackageloaded{tabulary}{\input{tabulary-luapersian.def}}{}
\@ifpackageloaded{tikz}{\input{tikz-luapersian.def}}{}
\@ifpackageloaded{tocbibind}{\@ifclassloaded{memoir}{}{\input{tocbibind-luapersian.def}}}{}
\@ifpackageloaded{tocloft}{\input{tocloft-luapersian.def}}{}
\@ifpackageloaded{wrapfig}{\input{wrapfig-luapersian.def}}{}






\DeclareOption{localise}{\input{localise-luapersian.def}}
\DeclareOption{quickindex}{%
\ifwritexviii%
\@ifclassloaded{memoir}{\PackageError{luapersian}{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{luapersian}{“shell escape” (or “write18”) is not enabled. You need to run “lualatex --shell-escape” on your TeX document for this feature to work}{}
\fi}
\ExecuteOptions{localise}
\ProcessOptions
\endinput
%% 
%% Copyright © 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 `luapersian.sty'.
