\documentclass[11pt]{thesis}
\usepackage{setspace,xargs}
% برای فاصله گذاری استاندارد بین خطوط و دستورات با چند آرگومان اختیاری
\usepackage{amsthm,amssymb,amsmath}
\usepackage{blkarray}
\usepackage{makeidx}
\usepackage[all]{xy}
%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
% footnote: =====================================================
%  برای اینکه پاورقی‌ها در هر صفحه ای از 1 شروع شوند 
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
%\usepackage{dblfnote} % دو ستون کردن پاورقی‌ها 

%=====================================================
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
\makeatletter
\newif\if@borderstar
\def\bordermatrix{\@ifnextchar*{%
        \@borderstartrue\@bordermatrix@i}{\@borderstarfalse\@bordermatrix@i*}%
}
\def\@bordermatrix@i*{\@ifnextchar[{\@bordermatrix@ii}{\@bordermatrix@ii[()]}}
\def\@bordermatrix@ii[#1]#2{%
    \begingroup
    \m@th\@tempdima8.75\p@\setbox\z@\vbox{%
        \def\cr{\crcr\noalign{\kern 2\p@\global\let\cr\endline }}%
        \ialign {$##$\hfil\kern 2\p@\kern\@tempdima & \thinspace %
            \hfil $##$\hfil && \quad\hfil $##$\hfil\crcr\omit\strut %
            \hfil\crcr\noalign{\kern -\baselineskip}#2\crcr\omit %
            \strut\cr}}%
    \setbox\tw@\vbox{\unvcopy\z@\global\setbox\@ne\lastbox}%
    \setbox\tw@\hbox{\unhbox\@ne\unskip\global\setbox\@ne\lastbox}%
    \setbox\tw@\hbox{%
        $\kern\wd\@ne\kern -\@tempdima\left\@firstoftwo#1%
        \if@borderstar\kern2pt\else\kern -\wd\@ne\fi%
        \global\setbox\@ne\vbox{\box\@ne\if@borderstar\else\kern 2\p@\fi}%
        \vcenter{\if@borderstar\else\kern -\ht\@ne\fi%
            \unvbox\z@\kern-\if@borderstar2\fi\baselineskip}%
        \if@borderstar\kern-2\@tempdima\kern2\p@\else\,\fi\right\@secondoftwo#1 $%
    }\null \;\vbox{\kern\ht\@ne\box\tw@}%
    \endgroup
}
\makeatother
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%5

%%%%%%%%%%%%
%%%%%%%%%%%%%%
%%%%%%%%%%%
% فونت‌ها، نمادها و محیط‌های ams
%
\usepackage{float}
\usepackage [pagebackref=true, colorlinks, linkcolor=blue, citecolor=magenta, urlcolor=cyan] {hyperref}
% چنانچه قصد پرینت گرفتن نوشته خود را دارید، خط بالا را غیرفعال و  از دستور زیر استفاده کنید. در ضمن pagebackref برای نشان دادن شماره صفحه ارجاعات مراجع در بخش bibliography است.
%\usepackage[pagebackref=false]{hyperref}
\hypersetup{
pdftitle={Thesis Title},
pdfauthor={akbar davoodi},
pdfsubject={Master Thesis},
pdfkeywords={keywords},
pdfdirection={R2L}
}
\usepackage{graphicx,xcolor}
\graphicspath{{./images/}}
% پکیج رنگ و گرافیک و تعریف پوشه عکس‌ها
\usepackage [a4paper, bindingoffset=-.5cm, footskip=1cm, headheight = 16pt, top=3cm, bottom=2.5cm,  right=3cm,  left=3cm ] {geometry}
% ابعاد صفحه و حاشیه‌ها
\usepackage{fancyhdr}
% تنظیم Heading
\usepackage{cite}
% تنظیم ارجاعات
\usepackage[nottoc]{tocbibind}
% اضافه کردن مراجع و نمایه به فهرست مطالب
\usepackage[textfont=it]{caption}

\usepackage{titletoc}
\usepackage{xcolor}
\usepackage{tikz}



% Glossaaires__________________________________________________ 

\usepackage[xindy={language=persian,codepage=utf8},toc]{glossaries}
%
\renewcommand\glsnamefont[1]{\rm #1}
%
\newglossarystyle{listdotpage}{%
    \glossarystyle{listgroup}
    \renewcommand*{\glossaryentryfield}[5]{%
      \item[\glstarget{##1}{##2}, ##5] \dotfill\space ##3}}
%
\newglossarystyle{listpagedot}{%
    \glossarystyle{listgroup}
    \renewcommand*{\glossaryentryfield}[5]{%
      \item[\glstarget{##1}{##2}] \dotfill\space \rl{, ##5}##3}}
%
      \newglossarystyle{notation}{%
    \glossarystyle{list}
    \renewcommand*{\glossaryentryfield}[5]{%
     \item[\parbox{1.3cm}{\LTR{\glstarget{##1}{##2}}}] \hspace{5pt} ##3,\space ##5}}
%
\renewcommand{\glossaryname}{واژه‌نامه فارسی به انگلیسی و نمایه}
%\renewcommand{\entryname}{\rl{نماد}}
%\renewcommand{\descriptionname}{\rl{توضیح}}
%\renewcommand{\pagelistname}{\rl{صفحه}}
%\setlength{\glsdescwidth}{60pt}
%
\newglossary[epx]{dicep}{epi}{epd}{واژه‌نامه انگلیسی به فارسی}
\GlsSetXdyLanguage[dicep]{english}
\makeglossaries
\loadglsentries{./chapters/dic.tex}
%\glsdisablehyper
\renewcommand\glsdisplayfirst[4]{\textit{#1}}
%\newcommand\gi[1]{\gls{#1}\index{\glsentrysort{#1}@\glsentrytext{#1}}}
\newcommand\gi[1]{\gls{#1}\glslink{ep#1}{}}
% دستور درج کلمه و اضافه شدن به واژه نامه
\newcommand\gn[1]{\glsentrytext{#1}}
% دستور درج کلمه بدون اضافه شدن به واژه نامه
\newcommand\gfirst[1]{\glsreset{#1}\gls{#1}\glslink{ep#1}{}}
% دستور درج کلمه به صورت ظهور اولین بار و اضافه شدن به واژه نامه
%   XePersian____________________________________________________ 
\usepackage{titlesec}
\usepackage{xepersian}
\usepackage{./styles/tempfix}
\settextfont[Scale=1.2]{XB Zar}
\setdigitfont[Scale=1.1]{PGaramond}
%\setlatintextfont[ExternalLocation,BoldFont={lmroman10-bold},BoldItalicFont={lmroman10-bolditalic},ItalicFont={lmroman10-italic}]{lmroman10-regular}
\defpersianfont\nastaliq[Scale=2]{IranNastaliq}
\defpersianfont\titr[Scale=1]{XB Titre}
\defpersianfont\traffic[Scale=1]{B Traffic}
%%

%\titlespacing*{\sectionHlpcH*4H*2.3}[lpc] 
%   Titles__________________________________________________________
\renewcommand{\abstractname}{\Large چکیده}
\renewcommand{\listfigurename}{فهرست تصاویر}
\renewcommand{\latinabstract}{}
\renewcommand{\proofname}{\textbf{برهان}}
\renewcommand{\qedsymbol}{$\blacksquare$}
\renewcommand{\bibname}{مراجع}
\newcommand{\sectionname}{}
%    Environments_________________________________________________ 
\newcounter{theorem}[section]
%\par\noindent\space
\newcommand{\environ}[2]{\vspace{7pt}\refstepcounter{theorem}\par \noindent \textbf{\hboxR{#1}\space\thetheorem} \text{ \hboxR{#2} } }
\newcommand{\closeenviron}{\par\vspace{3pt}}

\newenvironment{thm}[1][]{\environ{قضیه}{#1}\it}{\closeenviron}
\newenvironment{lem}[1][]{\environ{لم}{#1}\it}{\closeenviron}
\newenvironment{prop}[1][]{\environ{گزاره}{#1}\it}{\closeenviron}
\newenvironment{cor}[1][]{\environ{نتیجه}{#1}\it}{\closeenviron}
\newenvironment{con}[1][]{\environ{حدس}{#1}\it}{\closeenviron}
\newenvironment{dfn}[1][]{\environ{تعریف}{#1}\rm}{‌ \closeenviron}
\newenvironment{notation}[1][]{\environ{نماد}{#1}\rm}{‌\closeenviron}
\newenvironment{rem}[1][]{\environ{تبصره}{#1}\rm}{\closeenviron}
\newenvironment{exm}[1][]{\environ{مثال}{#1}\rm}{‌\closeenviron}
%
\makeatletter
\newenvironment{prob}[4]{\@ifempty{#1}
{\vspace{15pt} \par\noindent
\parbox{15cm}{\hskip 7pt\underline{\bf #2}\\[4pt]
\begin{tabular}{p{40pt}l}
\textbf{نمونه:}& \parbox[t]{11.8cm}{#3}\\[7pt]
\textbf{سوال:}& \parbox[t]{11.8cm}{#4}
\end{tabular}\vspace{5pt}
}}
{\vspace{5pt} \par\noindent
\parbox{15cm}{\hskip 7pt\underline{\bf #2}\\[4pt]
\begin{tabular}{p{40pt}l}
\textbf{ثابت‌ها:}& \parbox[t]{11.5cm}{#1}\\[4pt]
\textbf{نمونه:}& \parbox[t]{11.5cm}{#3}\\[7pt]
\textbf{سوال:}& \parbox[t]{11.5cm}{#4}
\end{tabular}\vspace{5pt}
}}} {\\[5pt]}
\makeatother
%  table of contents ______________________________________________

\titleformat{\chapter}[display]{ \filright\Huge}
{\enspace \chaptername\  \thechapter}
{6pt}{\bfseries\filleft}
%برخی تنظیمات برای عنوان فهرست مطالب
\titlecontents{chapter} [3pc] 
{\color{blue!50}\titlerule[3pt]\addvspace{1pc}\bfseries \filleft} 
{\color{black}\contentslabel 
[{\chaptername}
\thecontentslabel]{3pc}} 
{\color{black}}{\color{black}\hfill\contentspage} 
[\addvspace{1pc}] 
%تنظیم نوع فهرست مطالب
\titlecontents{section}[4pc]{\addvspace{2pt}\filleft} 
{\contentslabel[\sectionname\ \thecontentslabel\ ]{3pc}} 
{}{\dotfill \contentspage} 

%   Counters ___________________________________________________
\def\thesection{\arabic{section}.\thechapter}
\def\thesubsection{\arabic{subsection}.\thesection}
\def\theequation{\arabic{equation}.\thechapter}
\def\thetheorem{\arabic{theorem}.\thesection}
\def\thefigure{\arabic{figure}.\thechapter}
\def\thetable{\arabic{table}.\thechapter}
%\numberwithin{equation}{section}
%   Main body__________________________________________________
%\blacksquare
\headheight = 20pt
\pagestyle{plain}
\fancyhf{}
\doublespacing
\allowdisplaybreaks[1]