% در این فایل، دستورها و تنظیمات مورد نیاز، آورده شده است.
%-------------------------------------------------------------------------------------------------------------------
\usepackage{setspace,xargs}
% در ورژن جدید زی‌پرشین برای تایپ متن‌های ریاضی، این سه بسته، حتماً باید فراخوانی شود
\usepackage{amsthm,amssymb,amsmath}
\usepackage{fancybox,fancyvrb,enumerate,datetime}
\usepackage{datenumber}
\usepackage[usenames,dvipsnames]{color}
\usepackage{nameref}
%\usepackage[english]{babel}
\usepackage{pdflscape}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes,decorations,shadows}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{fadings}
\usetikzlibrary{patterns}
\usetikzlibrary{calc}
\allowdisplaybreaks
% برای رسم گراف دو دستور زیر مورد نیاز است
\usetikzlibrary{matrix,arrows}
%\usepackage{tikz-cd}

\usepackage{verbatim,sectsty,lipsum,graphicx,xcolor}
\graphicspath{{./images/}}
\usepackage{color}


% بسته‌ای برای تنطیم حاشیه‌های بالا، پایین، چپ و راست صفحه برای oneside
\usepackage[top=30mm, bottom=30mm, left=26mm, right=34mm]{geometry}
% بسته‌ای برای تنطیم حاشیه‌های بالا، پایین، چپ و راست صفحه برای twoside
%\usepackage[top=30mm, bottom=30mm, inner=30mm, outer=20mm]{geometry}
% بسته‌‌ای برای ظاهر شدن شکل‌ها و تصاویر متن
%\usepackage{graphicx}
\usepackage{picinpar,float,subfig,wrapfig,lipsum,pifont}%cite
\usepackage{titlesec}
% تنظیم ارجاعات

\makeatletter
\long\def\figwindownonum[#1,#2,#3,#4]{
\begin{window}[#1,#2,{#3}, {\centering#4\par}]}
\def\endfigwindownonum{\end{window}}  
\makeatother 

%\definecolor{brown}{rgb}{1,0,5,0}
% بسته‌ای برای رسم کادر
\usepackage{framed} 
\usepackage{pifont}
% بسته‌‌ای برای چاپ شدن خودکار تعداد صفحات در صفحه «معرفی پایان‌نامه»
\usepackage{lastpage}
% بسته‌ و دستوراتی برای ایجاد لینک‌های رنگی با امکان جهش
\usepackage[sort&compress, comma, numbers]{natbib}
\usepackage[colorlinks=true,linkcolor=Violet,citecolor=Red,urlcolor=Plum]{hyperref}
\renewcommand*{\backreflastsep}{, }
\renewcommand*{\backreftwosep}{, }
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{%
  \ifcase #1 %
    \relax %
  \or
    \lr{(page #2)}
  \else
     \lr{(page #2)}
  \fi%
}
% چنانچه قصد پرینت گرفتن نوشته خود را دارید، خط بالا را غیرفعال و  از دستور زیر استفاده کنید چون در صورت استفاده از دستور زیر‌‌، 
% لینک‌ها به رنگ سیاه ظاهر خواهند شد که برای پرینت گرفتن، مناسب‌تر است
%\usepackage[pagebackref=false]{hyperref}

\usepackage[textfont=it]{caption}
% ========================================= Glossaaires
\usepackage[xindy={language=persian,codepage=utf8},toc]{glossaries}
%\usepackage[xindy={language=english,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{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{fancyhdr}
% بسته‌ای برای ظاهر شدن «مراجع»  در فهرست مطالب
%\usepackage[nottoc]{tocbibind}
%\usepackage[nottoc,notlof,notlot]{tocbibind}
\usepackage[extrafootnotefeatures]{xepersian}
\twocolumnfootnotes


% دستورات مربوط به ایجاد نمایه
\usepackage{makeidx}
\makeindex


%%%%%%%%%%%%%%%%%%%%%%%%%%
%\renewcommand{\baselinestretch}{1.5}


% فراخوانی بسته زی‌پرشین و تعریف قلم فارسی و انگلیسی
\usepackage{xepersian}

 \newcommand{\counterexamples}[1]{
1$\Longleftarrow$ #1{1}

2 $\Longleftarrow$ #1{2}

3 $\Longleftarrow$ #1{3}

4 $\Longleftarrow$ #1{4}

5 $\Longleftarrow$ #1{5}

6 $\Longleftarrow$ #1{6}
 }

\newsavebox\mybox
\newenvironment{myfbox}{
\begin{lrbox}{\mybox}
\begin{minipage}{\dimexpr(\textwidth-2\fboxsep-2\fboxrule)}
}{
\end{minipage}
\end{lrbox}%
\vskip10pt
\noindent
\fbox{\usebox\mybox}%
\vskip10pt
}
\newenvironment{myshadowbox}{%
\begin{lrbox}{\mybox}%
\begin{minipage}{\dimexpr(\textwidth-2\fboxsep-2\fboxrule-\shadowsize)}
}{%
\end{minipage}
\end{lrbox}%
\vskip10pt
\noindent
\shadowbox{\usebox\mybox}%
\vskip10pt
}


\settextfont[Scale=1.1]{XB Niloofar}
%%%%%%%%%%%%%%%%%%%%%%%%%%
% چنانچه می‌خواهید اعداد در فرمول‌ها، انگلیسی باشد، خط زیر را غیرفعال کنید
% source \setdigitfont[Scale=1.1]{Persian Modern}
 \setdigitfont[Scale=1.1]{PGaramond}
%\setdigitfont[Scale=1.1]{Yas}
%%%%%%%%%%%%%%%%%%%%%%%%%%
% تعریف قلم‌های فارسی و انگلیسی اضافی برای استفاده در بعضی از قسمت‌های متن
\defpersianfont\nastaliq[Scale=2]{IranNastaliq}
\defpersianfont\chapternumber[Scale=3]{XB Niloofar}
\defpersianfont\titr[Scale=1]{XB Titre}
\defpersianfont\traffic[Scale=1]{B Traffic}
\defpersianfont\koodak[Scale=1]{B Koodak}
%\defpersianfont\xbkayhan[Scale=1]{XB Kayhan}
%\defpersianfont\xbkayhanpook[Scale=1]{XB Kayhan Pook}
%\defpersianfont\xbkayhansayeh[Scale=1]{XB Kayhan Sayeh}
%\defpersianfont\xbkayhannavaar[Scale=1]{XB Kayhan Navaar}
%\setpookfont{XB Titre}
%\setsayehfont{XB Titre}
%\setnavarfont{XB Titre}

%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\contentsname}{\centerline{فهرست مطالب}}
% دستوری برای حذف کلمه «چکیده»
\renewcommand{\abstractname}{}
% دستوری برای حذف کلمه «abstract»
\renewcommand{\latinabstract}{}
% دستوری برای تغییر نام کلمه «اثبات» به «برهان»
\renewcommand\proofname{\textbf{برهان}}
\renewcommand\qedsymbol{$\blacksquare$}
% دستوری برای تغییر نام کلمه «کتاب‌نامه» به «مراجع»
\renewcommand{\bibname}{مراجع}
% دستوری برای تعریف واژه‌نامه انگلیسی به فارسی
\newcommand\persiangloss[2]{#1\dotfill\lr{#2}\\}
% دستوری برای تعریف واژه‌نامه فارسی به انگلیسی 
\newcommand\englishgloss[2]{#2\dotfill\lr{#1}\\}
% تعریف دستور جدید «\پ» برای خلاصه‌نویسی جهت نوشتن عبارت «پروژه/پایان‌نامه/رساله»
\newcommand{\پ}{پروژه/پایان‌نامه/رساله }

\newcommand{\Index}[1]{#1\index{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%
% تعریف و نحوه ظاهر شدن عنوان قضیه‌ها، تعریف‌ها، مثال‌ها و ...
\newtheoremstyle{note}% name
{0\baselineskip}% Space above
{0\baselineskip}% Space below
{}% Body font
{}% Indent amount
{\bfseries}% Theorem head font
{.}% Punctuation after theorem head
{.5em}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning ‘normal’ )
\theoremstyle{definition}
\theoremstyle{note}
\newtheorem{definition}{تعریف}[section]
\theoremstyle{note}
\newtheorem{thm}[definition]{قضیه}
\theoremstyle{note}
\newtheorem{lemma}[definition]{لم}
\theoremstyle{note}
\newtheorem{prop}[definition]{گزاره}
\theoremstyle{note}
\newtheorem{cor}[definition]{نتیجه}
\theoremstyle{note}
\newtheorem{remark}[definition]{ملاحظه}
%\theoremstyle{definition}
\theoremstyle{note}
\newtheorem{exam}[definition]{مثال}
\theoremstyle{note}
\newtheorem{note}[definition]{نکته}
\theoremstyle{note}
\newtheorem{prob}[definition]{قرارداد}
\theoremstyle{note}
\newtheorem{Rem}[definition]{توجه}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newlength\st@shadowoffsetx
\newlength\st@shadowoffsety
\st@shadowoffsetx=1pt
\st@shadowoffsety=1pt
\newcommand\shadowoffset[1]{\setlength\st@shadowoffsetx{#1}\setlength\st@shadowoffsety{#1}}
\newcommand\shadowoffsetx[1]{\setlength\st@shadowoffsetx{#1}}
\newcommand\shadowoffsety[1]{\setlength\st@shadowoffsety{#1}}
\newcommand\shadowcolor[1]{\definecolor{st@shadowcolor}{rgb}{#1}}
\shadowcolor{0.66,0.66,0.66}
\newlength\@sbw
\newlength\@sbh 
\newlength\@picw
\newlength\@pich
\newcommand\shadowtext[1]%
{%
   \settowidth{\@sbw}{#1}%
   \settoheight{\@sbh}{#1}%
   \setlength{\@picw}{\@sbw}%
   \setlength{\@pich}{\@sbh}%
   \addtolength{\@picw}{\st@shadowoffsetx}%
   \addtolength{\@pich}{\st@shadowoffsety}%
   %
   \edef\num@tw{\strip@pt\@sbw}%
   \edef\num@th{\strip@pt\@sbh}%
   \edef\num@pw{\strip@pt\@picw}%
   \edef\num@ph{\strip@pt\@pich}%
   \edef\num@offsetx{\strip@pt\st@shadowoffsetx}%
   \edef\num@offsety{\strip@pt\st@shadowoffsety}%
   \begin{picture}(\num@pw,\num@ph)(0,0)
	    \put(\num@offsetx,0){\makebox(\num@tw,\num@th)[tl]{{\color{st@shadowcolor}\def\color##1{}\ignorespaces #1}}}
		\put(0,\num@offsety){\makebox(\num@tw,\num@th)[tl]{\if@RTL\beginR\fi\ignorespaces #1\if@RTL\endR\fi}}
	\end{picture}\ignorespaces%
}
\makeatother
%برای وسط چین شدن عنوان فصل ها
%\makeatletter\def\@makechapterhead#1{
%\vspace*{50\p@}{
%\parindent \z@ \centering \normalfont
%\ifnum \c@secnumdepth >\m@ne\huge\bfseries \@chapapp\space \thechapter\par\nobreak
%\vskip 20\p@\fi \interlinepenalty\@M\Huge \bfseries #1\par\nobreak\vskip 40\p@
%}
%}
%\makeatother    

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% دستورهایی برای سفارشی کردن سربرگ صفحات
\csname@twosidetrue\endcsname
\pagestyle{fancy}
\fancyhf{} 
\fancyhead[OL,EL]{\thepage}
\fancyhead[OR]{\small\rightmark}
\fancyhead[ER]{\small\leftmark}
\renewcommand{\chaptermark}[1]{%
\markboth{\thechapter.\ #1}{}}

%برای وسط چین شدن عنوان فصل ها
%%%%%%% 93-05-10 %%\normalfont
\makeatletter

\def\@makechapterhead#1{
  \vspace*{50\p@}
  {\parindent \z@ \centering\normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \LARGE \bfseries \@chapapp\space \@tartibi\thechapter
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\def\@makeschapterhead#1{
  \vspace*{50\p@}
  {\parindent \z@ \centering
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}
  \makeatother

%برای تغییر آ به الف در شمارنده‌ی harfi 
\makeatletter
\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 ی\else\@ctrerr\fi}
\makeatother

%%برای روزهفته 
%\makeatletter
%\def\@datedayname#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 ی\else\@ctrerr\fi}
%\makeatother


\providecommand*{\datedayname}[1]{%
\ifcase#1\relax
\or یکشنبه
\or دوشنبه%
\or سه‌شنبه%
\or چهارشنبه%
\or پنجشنبه%
\or جمعه%
\or شنبه%
\fi}