summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-07-12 18:14:02 +0000
committerKarl Berry <karl@freefriends.org>2008-07-12 18:14:02 +0000
commit037cf3d536e0f1fa1cccb00e1f26e8279abceb40 (patch)
tree16cf8df937bb5cca317457bf957d2aa881f0e4a1 /Master/texmf-dist/tex/xelatex
parent571a59707cdc614327b51de4a2494eddf9410042 (diff)
new xelatex package xepersian
git-svn-id: svn://tug.org/texlive/trunk@9484 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex')
-rw-r--r--Master/texmf-dist/tex/xelatex/xepersian/persianpoem.sty220
-rw-r--r--Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty523
2 files changed, 743 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xepersian/persianpoem.sty b/Master/texmf-dist/tex/xelatex/xepersian/persianpoem.sty
new file mode 100644
index 00000000000..8aed77da7b5
--- /dev/null
+++ b/Master/texmf-dist/tex/xelatex/xepersian/persianpoem.sty
@@ -0,0 +1,220 @@
+%%
+%% This is file `poem.sty',
+%% Copyright(C) 2002, 2004 Behdad Esfahbod <behdad@farsitex.org>
+%%
+%% It may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.2
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.2 or later is part of all distributions of LaTeX
+%% version 1999/12/01 or later.
+%%
+%% TODO: Add some penalties and whistles to newpoem
+%%
+\ifx\fmtname{LaTeX2e}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{persianpoem}%
+ [2004/09/27 Environments for Setting Persian Poetry]
+\else
+ \typeout{2004/09/27 Environments for Setting Persian Poetry}
+\fi
+
+\def\poemcolsepskip{.1\versewidth plus .1\versewidth minus .05\versewidth}
+\def\poemmarginskip{1em plus 1fil minus 1em}
+\def\poemextrabaselineskip{0\baselineskip}
+\def\poemskip{\medskip}
+\def\poemblocksep{\quad$\Box$}
+
+%% oldpoem environment
+
+\newdimen\versewidth
+
+\def\poem@verse#1{%
+ \ifdim\wd#1>\new@poem@width
+ \xdef\new@poem@width{\the\wd#1}%
+ \ifdim\new@poem@width>\poem@width
+ \xdef\poem@width{\new@poem@width}%
+ \global\let\poem@needrun\relax
+ \fi
+ \fi
+ \hbox to\poem@width{\unhbox#1}%
+}
+\def\poem@linebegin{\vadjust{}\hskip\@flushglue\hskip\poemmarginskip\relax}
+\def\poem@lineend{\nobreak\hskip\poemmarginskip\hskip\@flushglue\vadjust{}}
+\def\poem@lineversesep{%
+ \nobreak
+ \hskip\z@ plus 1filll%
+ \penalty600%
+ \hskip\poemcolsepskip
+ \hskip\z@ plus -2filll%
+ \vadjust{}%
+ \nobreak
+ \hskip\z@ plus 1filll%
+}
+
+\def\poem@lineparsebegin{%
+ \halign\bgroup
+ \global\setbox\verse@i=\hbox{\ignorespaces##\unskip}&&
+ \global\setbox\verse@ii=\hbox{\ignorespaces##\unskip}
+ \cr
+}
+\def\poem@lineparseend{%
+ \crcr\egroup
+ \vskip-\baselineskip
+}
+\def\oldpoem@cr{%
+ \cr\poem@line
+}
+
+\newbox\verse@i
+\newbox\verse@ii
+\newif\ifpoem@started
+
+\def\poem@line{%
+ \poem@lineparseend
+%
+ \ifdim\wd\verse@i>\z@\global\poem@startedtrue\fi
+ \ifdim\wd\verse@ii>\z@\global\poem@startedtrue\fi
+ \ifpoem@started
+ \ifdim\wd\verse@ii>\z@\else
+ \nopagebreak[3]
+ \fi
+ \leavevmode
+ \poem@linebegin
+ \poem@verse\verse@i
+ \ifdim\wd\verse@ii>\z@
+ \poem@lineversesep
+ \poem@verse\verse@ii
+ \fi
+ \poem@lineend
+ \nopagebreak
+ \endgraf
+ \vskip\poemextrabaselineskip
+ \fi
+%
+ \poem@lineparsebegin
+}
+\def\@oldpoem{%
+ \stepcounter{poem@no}
+ \ifnum\max@poem@no<\number\c@poem@no%
+ \xdef\poem@width{\z@}%
+ \else
+ \xdef\poem@width{\poem@prop{poem@width}}%
+ \fi
+ \xdef\new@poem@width{\z@}%
+ \global\versewidth=\poem@width
+ \poemskip\leavevmode\par
+ \begingroup
+ \tabskip=\z@
+ \parskip=\z@
+ \parindent=\z@
+ \parfillskip=\z@
+ \rightskip=\z@
+ \leftskip=\z@
+ \widowpenalty=10000% No break between verses of the same line.
+ \clubpenalty=10000% Same as above. Not really needed.
+ \def\newblock{\hfil\poemblocksep\hfil\null}%
+ \def\par{\oldpoem@cr}% Redefine \par for possible \obeylines
+ \def\\{\global\poem@startedtrue\oldpoem@cr}%
+ \global\poem@startedfalse
+ \csname poem@obeylines\endcsname
+ \let\poem@obeylines\relax
+ \poem@lineparsebegin
+}
+\def\@endoldpoem{%
+ \cr
+ \ifdim\wd\verse@i>\z@\poem@line\else\ifdim\wd\verse@ii>\z@\poem@line\else
+ \noalign{%
+ \skip0=\poemextrabaselineskip
+ \vskip-\skip0
+ \vskip-\baselineskip
+ }%
+ \fi\fi
+ \poem@lineparseend
+ \endgroup
+ \par
+ \vskip\baselineskip
+ \poemskip
+ \ifdim\new@poem@width<\poem@width
+ \global\let\poem@needrun\relax
+ \fi
+ \poem@write@aux{poem@width@\romannumeral\c@poem@no}{\new@poem@width}%
+ \ifx\AtEndDocument\undefined\poem@finish\fi
+}
+\newenvironment{oldpoem}{\@oldpoem}{\@endoldpoem}
+
+\expandafter\def\csname oldpoem*\endcsname{\let\poem@obeylines=\obeylines\oldpoem}
+\expandafter\def\csname endoldpoem*\endcsname{\endoldpoem}
+
+
+\def\poem@finish{%
+ \poem@write@aux{max@poem@no}{\number\c@poem@no}%
+ \ifx\poem@needrun\relax
+ \@@warning{Unjustified poetry. Rerun to get poems right}%
+ \global\let\poem@needrun\undefined
+ \fi
+}
+\ifx\AtEndDocument\undefined\else\AtEndDocument\poem@finish\fi
+
+\newcounter{poem@no}\setcounter{poem@no}{\z@}
+\ifx\max@poem@no\undefined
+ \def\max@poem@no{0}%
+\fi
+
+\newcommand{\poem@prop}[1]{\@nameuse{#1@\romannumeral\c@poem@no}}
+
+\newcommand{\poem@write@aux}[2]{%
+ \def\@x{\immediate\write\@auxout{\global\noexpand\@namedef{#1}{#2}}}%
+ \@x
+}
+
+%% newpoem environment
+
+\def\@newpoem{%
+ \par
+ \begingroup
+ \parskip=\z@
+ \parindent=\z@
+ \def\[{\@settab\@tabplus\ignorespaces}%
+ \def\]{\@tabminus\ignorespaces}%
+ \def\newblock{\poemblocksep}%
+ \let\newpoem@tabcr\@tabcr
+ \def\par{% Redefine \par for possible \obeylines
+ \ifpoem@started\else
+ \ifdim\wd\@curline>\z@\global\poem@startedtrue\else
+ \@stopfield
+ \ifdim\wd\@curfield>\z@\global\poem@startedtrue\fi
+ \@contfield
+ \fi
+ \fi
+ \ifpoem@started\newpoem@tabcr\fi}%
+ \def\@tabcr{\global\poem@startedtrue\newpoem@tabcr}%
+ \global\poem@startedfalse
+ \csname poem@obeylines\endcsname
+ \let\poem@obeylines\relax
+ \begin{tabbing}%
+}
+\def\@endnewpoem{%
+ \global\poem@startedfalse
+ \ifdim\wd\@curline>\z@\global\poem@startedtrue\else
+ \@stopfield
+ \ifdim\wd\@curfield>\z@\global\poem@startedtrue\fi
+ \@contfield
+ \fi
+ \ifpoem@started\else\let\@stopline\@stopfield\fi
+ \end{tabbing}%
+ \endgroup
+ \par
+}
+
+\newenvironment{newpoem}{\@newpoem}{\@endnewpoem}
+
+\expandafter\def\csname newpoem*\endcsname{\let\poem@obeylines=\obeylines\newpoem}
+\expandafter\def\csname endnewpoem*\endcsname{\endnewpoem}
+
+
+\endinput
+%%
+%% End of file `poem.sty'.
+
diff --git a/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty b/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty
new file mode 100644
index 00000000000..d647998cfc9
--- /dev/null
+++ b/Master/texmf-dist/tex/xelatex/xepersian/xepersian.sty
@@ -0,0 +1,523 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{xepersian}[2008/07/11 v0.16
+ Typesetting Persian with XeTeX]
+\RequirePackage{amssymb}
+\RequirePackage{graphicx}
+\RequirePackage{fontspec}
+\RequirePackage{amsmath,amsthm}
+\RequirePackage{xunicode,bidi}
+\RequirePackage{arabxetex}
+\RequirePackage{xltxtra}
+\RequirePackage{persianpoem,fmultico}
+\RequirePackage{xcolor}
+\newfontinstance\farsifont[Script=Arabic,Scale=1.2,Mapping=farsidigits]{Nazli}
+\newfontinstance\arabicfont[Script=Arabic,Scale=1.2]{Scheherazade}
+\newfontinstance\logofont[Script=Arabic,Scale=1.2]{IranNastaliq}
+\makeatletter
+\renewcommand{\thepage}{\textfarsi{\the\c@page}}
+\renewcommand{\thepart}{\textfarsi{\the\c@part}}
+%
+\renewcommand{\thefootnote}{\textfarsi{\arabic{footnote}}}
+\renewcommand{\thefigure}{\textfarsi{\arabic{figure}}}
+\renewcommand{\thetable}{\textfarsi{\arabic{table}}}
+\renewcommand{\theequation}{\textfarsi{\arabic{equation}}}
+%
+\renewcommand{\figurename}{\textfarsi{شکل}}
+\renewcommand{\tablename}{\textfarsi{جدول}}
+\renewcommand{\contentsname}{\textfarsi{فهرست مطالب}}%
+\renewcommand{\listfigurename}{\textfarsi{لیست تصاویر}}%
+\renewcommand{\listtablename}{\textfarsi{لیست جداول}}%
+\renewcommand{\appendixname}{\textfarsi{پیوست}}%
+\renewcommand{\indexname}{\textfarsi{نمایه}}%
+\@ifclassloaded{article}{%
+\renewcommand{\thesection}{\textfarsi{\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\refname}{\textfarsi{مراجع}}%
+\renewcommand{\abstractname}{\textfarsi{چکیده}}%
+\RequirePackage{makeidx}
+\RequirePackage{robustindex}
+\makeindex
+}{}
+\@ifclassloaded{amsart}{%
+\renewcommand{\thesection}{\textfarsi{\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\refname}{\textfarsi{مراجع}}%
+\renewcommand{\abstractname}{\textfarsi{چکیده}}%
+\RequirePackage{robustindex}
+\makeindex
+}{}
+\@ifclassloaded{report}{%
+\renewcommand{\thechapter}{\textfarsi{\the\c@chapter}}
+\renewcommand{\thesection}{\textfarsi{\the\c@chapter.\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\bibname}{\textfarsi{کتاب‌نامه}}%
+\renewcommand{\abstractname}{\textfarsi{چکیده}}%
+\renewcommand{\chaptername}{\textfarsi{فصل}}%
+\renewcommand{\partname}{\textfarsi{بخش}}%
+\RequirePackage{makeidx}
+\RequirePackage{robustindex}
+\makeindex
+}{}
+\@ifclassloaded{amsbook}{%
+\renewcommand{\thechapter}{\textfarsi{\the\c@chapter}}
+\renewcommand{\thesection}{\textfarsi{\the\c@chapter.\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\bibname}{\textfarsi{کتاب‌نامه}}%
+\renewcommand{\chaptername}{\textfarsi{فصل}}%
+\renewcommand{\partname}{\textfarsi{بخش}}%
+\RequirePackage{robustindex}
+\makeindex
+}{}
+\@ifclassloaded{bookest}{%
+\NoHyper
+\renewcommand{\thechapter}{\textfarsi{\the\c@chapter}}
+\renewcommand{\thesection}{\textfarsi{\the\c@chapter.\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\bibname}{\textfarsi{کتاب‌نامه}}%
+\renewcommand{\chaptername}{\textfarsi{فصل}}%
+\renewcommand{\partname}{\textfarsi{بخش}}%
+\RequirePackage{makeidx}
+\RequirePackage{robustindex}
+\makeindex
+}{}
+\@ifclassloaded{book}{%
+\renewcommand{\thechapter}{\textfarsi{\the\c@chapter}}
+\renewcommand{\thesection}{\textfarsi{\the\c@chapter.\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\bibname}{\textfarsi{کتاب‌نامه}}%
+\renewcommand{\chaptername}{\textfarsi{فصل}}%
+\renewcommand{\partname}{\textfarsi{بخش}}%
+\RequirePackage{makeidx}
+\RequirePackage{robustindex}
+\makeindex
+}{}
+\@ifclassloaded{refrep}{%
+\renewcommand{\thechapter}{\textfarsi{\the\c@chapter}}
+\renewcommand{\thesection}{\textfarsi{\the\c@chapter.\the\c@section}}
+\renewcommand{\thesubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection}}
+\renewcommand{\thesubsubsection}{\textfarsi{\the\c@chapter.\the\c@section.\the\c@subsection.\the\c@subsubsection}}
+\renewcommand{\bibname}{\textfarsi{کتاب‌نامه}}%
+\renewcommand{\chaptername}{\textfarsi{فصل}}%
+\renewcommand{\partname}{\textfarsi{بخش}}%
+\RequirePackage{makeidx}
+\RequirePackage{robustindex}
+\makeindex
+}{}
+%\renewcommand{\prefacename}{\textfarsi{پیشگفتار}}%
+
+
+%To convert the MILADI date to SHAMSI date, taken from farsitex
+\newif\ifFT@leap \newif\ifFT@kabiseh
+\newcount\FT@i \newcount\FT@y \newcount\FT@m \newcount\FT@d
+\newcount\FT@latini \newcount\FT@farsii
+\newcount\FT@latinii \newcount\FT@farsiii
+\newcount\FT@latiniii \newcount\FT@farsiiii
+\newcount\FT@latiniv \newcount\FT@farsiiv
+\newcount\FT@latinv \newcount\FT@farsiv
+\newcount\FT@latinvi \newcount\FT@farsivi
+\newcount\FT@latinvii \newcount\FT@farsivii
+\newcount\FT@latinviii \newcount\FT@farsiviii
+\newcount\FT@latinix \newcount\FT@farsiix
+\newcount\FT@latinx \newcount\FT@farsix
+\newcount\FT@latinxi \newcount\FT@farsixi
+\newcount\FT@latinxii \newcount\FT@farsixii
+ \newcount\FT@farsixiii
+
+\newcount\FT@temp
+\newcount\FT@temptwo
+\newcount\FT@tempthree
+\newcount\FT@yModHundred
+\newcount\FT@thirtytwo
+\newcount\FT@dn
+\newcount\FT@sn
+\newcount\FT@mminusone
+
+\def\ftoday{%
+\FT@y=\year \FT@m=\month \FT@d=\day
+%
+\FT@temp=\FT@y
+\divide\FT@temp by 100\relax
+\multiply\FT@temp by 100\relax
+\FT@yModHundred=\FT@y
+\advance\FT@yModHundred by -\FT@temp\relax
+%
+\ifodd\FT@yModHundred
+ \FT@leapfalse
+\else
+ \FT@temp=\FT@yModHundred
+ \divide\FT@temp by 2\relax
+ \ifodd\FT@temp\FT@leapfalse
+ \else
+ \ifnum\FT@yModHundred=0%
+ \FT@temp=\FT@y
+ \divide\FT@temp by 400\relax
+ \multiply\FT@temp by 400\relax
+ \ifnum\FT@y=\FT@temp\FT@leaptrue\else\FT@leapfalse\fi
+ \else\FT@leaptrue
+ \fi
+ \fi
+\fi
+%
+\FT@latini=31\relax
+\ifFT@leap
+ \FT@latinii = 29\relax
+\else
+ \FT@latinii = 28\relax
+\fi
+\FT@latiniii = 31\relax
+\FT@latiniv = 30\relax
+\FT@latinv = 31\relax
+\FT@latinvi = 30\relax
+\FT@latinvii = 31\relax
+\FT@latinviii = 31\relax
+\FT@latinix = 30\relax
+\FT@latinx = 31\relax
+\FT@latinxi = 30\relax
+\FT@latinxii = 31\relax
+%
+\FT@thirtytwo=32\relax
+%
+\FT@temp=\FT@y
+\advance\FT@temp by -17\relax
+\FT@temptwo=\FT@temp
+\divide\FT@temptwo by 33\relax
+\multiply\FT@temptwo by 33\relax
+\advance\FT@temp by -\FT@temptwo
+\ifnum\FT@temp=\FT@thirtytwo\FT@kabisehfalse
+\else
+ \FT@temptwo=\FT@temp
+ \divide\FT@temptwo by 4\relax
+ \multiply\FT@temptwo by 4\relax
+ \advance\FT@temp by -\FT@temptwo
+ \ifnum\FT@temp=\z@\FT@kabisehtrue\else\FT@kabisehfalse\fi
+\fi
+%
+% --BE
+% In fact farsii is equal to the Leap years from a fixed year to the last
+% year minus the Kabise years from a fixed year to the last year plus a const.
+%
+\FT@tempthree=\FT@y % Number of Leap years
+\advance\FT@tempthree by -1
+\FT@temp=\FT@tempthree % T := (MY-1) div 4
+\divide\FT@temp by 4\relax
+\FT@temptwo=\FT@tempthree % T := T - ((MY-1) div 100)
+\divide\FT@temptwo by 100\relax
+\advance\FT@temp by -\FT@temptwo
+\FT@temptwo=\FT@tempthree % T := T + ((MY-1) div 400)
+\divide\FT@temptwo by 400\relax
+\advance\FT@temp by \FT@temptwo
+\advance\FT@tempthree by -611 % Number of Kabise years
+\FT@temptwo=\FT@tempthree % T := T - ((SY+10) div 33) * 8
+\divide\FT@temptwo by 33\relax
+\multiply\FT@temptwo by 8\relax
+\advance\FT@temp by -\FT@temptwo
+\FT@temptwo=\FT@tempthree %
+\divide\FT@temptwo by 33\relax
+\multiply\FT@temptwo by 33\relax
+\advance\FT@tempthree by -\FT@temptwo
+\ifnum\FT@tempthree=32\advance\FT@temp by 1\fi % if (SY+10) mod 33=32 then Inc(T);
+\divide\FT@tempthree by 4\relax % T := T - ((SY+10) mod 33) div 4
+\advance\FT@temp by -\FT@tempthree
+\advance\FT@temp by -137 % T := T - 137 Adjust the value
+\FT@farsii=31
+\advance\FT@farsii by -\FT@temp % now 31 - T is the farsii
+%
+\FT@farsiii = 30\relax
+\ifFT@kabiseh
+ \FT@farsiiii = 30\relax
+\else
+ \FT@farsiiii = 29\relax
+\fi
+\FT@farsiiv = 31\relax
+\FT@farsiv = 31\relax
+\FT@farsivi = 31\relax
+\FT@farsivii = 31\relax
+\FT@farsiviii= 31\relax
+\FT@farsiix = 31\relax
+\FT@farsix = 30\relax
+\FT@farsixi = 30\relax
+\FT@farsixii = 30\relax
+\FT@farsixiii= 30\relax
+%
+\FT@dn= 0\relax
+\FT@sn= 0\relax
+\FT@mminusone=\FT@m
+\advance\FT@mminusone by -1\relax
+%
+\FT@i=0\relax
+\ifnum\FT@i < \FT@mminusone
+\loop
+\advance \FT@i by 1\relax
+\advance\FT@dn by \csname FT@latin\romannumeral\the\FT@i\endcsname
+\ifnum\FT@i<\FT@mminusone \repeat
+\fi
+\advance \FT@dn by \FT@d
+%
+\FT@i=1\relax
+\FT@sn = \FT@farsii
+\ifnum \FT@sn<\FT@dn
+\loop
+\advance \FT@i by 1\relax
+\advance\FT@sn by \csname FT@farsi\romannumeral\the\FT@i\endcsname
+\ifnum \FT@sn<\FT@dn \repeat
+\fi
+\ifnum \FT@i < 4
+ \FT@m = 9 \advance\FT@m by \FT@i
+ \advance \FT@y by -622\relax
+\else
+ \FT@m = \FT@i \advance \FT@m by -3\relax
+ \advance \FT@y by -621\relax
+\fi
+\advance\FT@sn by -\csname FT@farsi\romannumeral\the\FT@i%
+\endcsname
+\ifnum\FT@i = 1
+ \FT@d = \FT@dn \advance \FT@d by 30 \advance\FT@d by -\FT@farsii
+\else
+ \FT@d = \FT@dn \advance \FT@d by -\FT@sn
+\fi
+\beginL\number\FT@d\endL\space%
+%Changedc from here YJ
+\farsimonth{\FT@m}\space\beginL\number\FT@y\endL%
+}
+% added \farsimonth YJ
+\def\farsimonth#1{\ifcase#1\or فروردین\or
+اردیبهشت\or
+خرداد\or تیر\or
+مرداد\or
+شهریور\or مهر\or
+آبان\or آذر\or
+دی\or بهمن\or
+اسفند\fi}
+
+%The figure or table caption
+\newsavebox\@Arabitempboxa
+\long\def\@makecaption#1#2{%
+ \vskip\abovecaptionskip
+ \sbox\@Arabitempboxa{\beginR #1: #2\endR}%
+ \ifdim \wd\@Arabitempboxa >\hsize
+ \beginR #1: #2\endR\par
+ \else
+ \global \@minipagefalse
+ \hb@xt@\hsize{\hfil\box\@Arabitempboxa\hfil}%
+ \fi
+ \vskip\belowcaptionskip}
+\makeatother
+\makeatletter
+%The correct the right footnorerule so it does not overlap the texts
+\def\r@fn{%
+ \hbox to \columnwidth
+ {\beginR \vbox{\kern -3\p@
+ \hrule width .4\columnwidth \kern2.6\p@}\hfil\endR}}
+\def\footnoterule{\r@fn}
+\makeatother
+
+
+%a command to put a footnote from left to right
+%while in a right to left context
+\newcommand{\Footnote}[1]{%
+\bgroup% To make the scope of the change local
+\footnotemark%
+\renewcommand{\thefootnote}{\arabic{footnote}}%
+\unsetRL%
+\footnotetext{#1}%
+\egroup
+}
+
+%we have to swap the following two characters
+%when we are in a Right-to-Left environment
+\makeatletter
+\catcode"00AB=\active%left double quote
+\catcode"00BB=\active%right double quote
+\def«{\if@rl\char"00BB\else\char"00AB\fi{}}
+\def»{\if@rl\char"00AB\else\char"00BB\fi{}}
+\makeatother
+
+%For Right-to-Left two column command, I guess taken from rlbabel
+\makeatletter
+\let\@old@outputdblcol\@outputdblcol
+\newcommand{\rl@outputdblcol}{%
+ \if@firstcolumn
+ \global \@firstcolumnfalse
+ \global \setbox\@leftcolumn \box\@outputbox
+ \else
+ \global \@firstcolumntrue
+ \setbox\@outputbox \vbox {\hb@xt@\textwidth {%
+ \hskip\columnwidth%
+ \hfil\vrule\@width\columnseprule\hfil
+ \hb@xt@\columnwidth {%
+ \box\@leftcolumn \hss}%
+ \hb@xt@\columnwidth {%
+ \hskip-\textwidth%
+ \box\@outputbox \hss}%
+ \hskip\columnsep%
+ \hskip\columnwidth}}%
+ \@combinedblfloats
+ \@outputpage
+ \begingroup
+ \@dblfloatplacement
+ \@startdblcolumn
+ \@whilesw\if@fcolmade \fi
+ {\@outputpage
+ \@startdblcolumn}%
+ \endgroup
+ \fi}
+\newcommand{\rldblcolumn}{\renewcommand{\@outputdblcol}{\rl@outputdblcol}}
+\newcommand{\lrdblcolumn}{\renewcommand{\@outputdblcol}{\@old@outputdblcol}}
+%set the default direction of the twocolumn texts to Right-to-Left
+\rldblcolumn
+\makeatother
+
+
+% define the XePersian logo
+\newcommand{\XePersian}{\leavevmode$\smash{\hbox{\XeTeX\lower.2ex
+ \hbox{\kern0em \color[rgb]{0,.6,0}\logofont پارسی}}}$}
+
+\newcommand{\eng}[1]{\textroman{ #1}}
+\newcommand{\fars}[1]{\textfarsi{#1}}
+\newcommand{\arabt}[1]{\textarabic{#1}}
+
+\makeatletter
+\let\@utitle=\title
+\def\title#1{\@utitle{\textfarsi{#1}}}
+\let\@uthor=\author
+\def\author#1{\@uthor{\textfarsi{#1}}}
+\let\@ufootnote=\footnote
+\def\footnote#1{\@ufootnote{\textfarsi{#1}}}
+\let\@uthanks=\thanks
+\def\thanks#1{\@uthanks{\textfarsi{#1}}}
+\def\today{\textfarsi{\ftoday}}
+\let\@urightmark=\rightmark
+\def\rightmark{\textfarsi{\@urightmark}}
+\let\@uleftmark=\leftmark
+\def\leftmark{\textfarsi{\@uleftmark}}
+\let\normalfont=\farsifont
+\let\@uframetitle=\frametitle
+\def\frametitle#1{\@uframetitle{\centerline{\textfarsi{#1}}}}
+\let\@uframesubtitle=\framesubtitle
+\def\framesubtitle#1{\@uframesubtitle{\centerline{\textfarsi{#1}}}}
+\let\@usubtitle=\subtitle
+\def\subtitle#1{\@usubtitle{\textfarsi{#1}}}
+\let\@uinstitute=\institute
+\def\institute#1{\@uinstitute{\textfarsi{#1}}}
+\let\@ucaption=\caption
+\def\caption#1{\@ucaption{\textfarsi{#1}}}
+\makeatother
+\makeatletter
+%To fix tabular problem in bidi. Taken from farsitex
+\newif\if@tabsw
+\global\@tabswfalse
+\def\@tabular{\if@rl\global\@tabswtrue\fi
+ \leavevmode \hbox \bgroup \if@tabsw\beginR\normalfont \fi
+ $\let\@acol\@tabacol
+ \let\@classz\@tabclassz
+ \let\@classiv\@tabclassiv \let\\\@tabularcr\@tabarray}
+\def\endtabular{\crcr\egroup\if@tabsw\egroup\endR\egroup\fi
+ \egroup $\if@tabsw\endR\fi \egroup
+ \global\@tabswfalse}
+\expandafter \let \csname endtabular*\endcsname = \endtabular
+
+\def\@array[#1]#2{\setbox\@arstrutbox=\hbox{\vrule
+ height\arraystretch \ht\strutbox
+ depth\arraystretch \dp\strutbox
+ width\z@}\@mkpream{#2}\edef\@preamble{%
+\halign \noexpand\@halignto
+\bgroup \tabskip\z@ \@arstrut \@preamble \tabskip\z@ \cr}%
+\let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
+\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
+\bgroup \let\par\relax
+\let\@sharp##\let\protect\relax \lineskip\z@\baselineskip\z@
+\if@tabsw\hbox\bgroup\beginR\vbox\bgroup\fi
+\@preamble}
+
+%taken from rlbabel.ldf
+\newif\if@rl
+\AtBeginDocument{% Here we set the main document direction
+ \newif\if@rlmain%
+ \if@rl% e.g: if the options to babel were [english,hebrew]
+ \@rlmaintrue%
+ \else% e.g: if the options to babel were [hebrew,english]
+ \@rlmainfalse%
+ \fi%
+}
+
+%To fix eqref problem taken from amsmath
+\let\@@text=\text
+\def\text#1{\@@text{\RL{#1}}}
+
+\def\tagform@#1{\maketag@@@{)\ignorespaces\text{#1}\unskip\@@italiccorr(}}
+\renewcommand{\eqref}[1]{(\ref{#1})}
+
+%To fix equation numbers. taken from amsmath
+{\renewenvironment{equation}{%
+ \unsetRL
+ \incr@eqnum
+ \mathdisplay@push
+ \st@rredfalse \global\@eqnswtrue
+ \mathdisplay{equation}%
+\setRL
+}{%
+\unsetRL
+ \endmathdisplay{equation}%
+ \mathdisplay@pop
+ \ignorespacesafterend
+\setRL
+}}
+\makeatother
+%to make the digits in math formula persian
+\font\tenrgm="Nazli" at 12pt
+\font\sevrgm="Nazli" at 10pt
+\font\fivrgm="Nazli" at 7pt
+\newfam\fardig
+\textfont\fardig=\tenrgm
+\scriptfont\fardig=\sevrgm
+\scriptscriptfont\fardig=\fivrgm
+\def\maths{
+ \XeTeXmathcode`0="7 \fardig "06F0%
+ \XeTeXmathcode`1="7 \fardig "06F1%
+ \XeTeXmathcode`2="7 \fardig "06F2%
+ \XeTeXmathcode`3="7 \fardig "06F3%
+ \XeTeXmathcode`4="7 \fardig "06F4%
+ \XeTeXmathcode`5="7 \fardig "06F5%
+ \XeTeXmathcode`6="7 \fardig "06F6%
+ \XeTeXmathcode`7="7 \fardig "06F7%
+ \XeTeXmathcode`8="7 \fardig "06F8%
+ \XeTeXmathcode`9="7 \fardig "06F9%
+ \XeTeXmathcode`.="7 \fardig "066B%decimal point
+}
+\XeTeXmathcode`٫="7 \fardig "066B%decimal point
+\XeTeXmathcode`۰="7 \fardig "06F0%
+\XeTeXmathcode`۱="7 \fardig "06F1%
+\XeTeXmathcode`۲="7 \fardig "06F2%
+\XeTeXmathcode`۳="7 \fardig "06F3%
+\XeTeXmathcode`۴="7 \fardig "06F4%
+\XeTeXmathcode`۵="7 \fardig "06F5%
+\XeTeXmathcode`۶="7 \fardig "06F6%
+\XeTeXmathcode`۷="7 \fardig "06F7%
+\XeTeXmathcode`۸="7 \fardig "06F8%
+\XeTeXmathcode`۹="7 \fardig "06F9%
+%to resolve a problem we encounter when using power
+%or index in math formula
+\makeatletter\def\arabtex@codes{}\makeatother
+\AtBeginDocument{\maths}
+
+
+
+\endinput
+
+
+
+
+
+
+
+
+
+
+
+