% !TEX TS-program = XeLaTeX
%%%  یک نمونه پروژه/پایان‌نامه/رساله با استفاده از کلاس AhmadMardi، نسخه 1.1
%%% احمد مردی، دانشگاه تربیت مدرس،       


%-----------------------------------------------------------------------------------------------------
%        توجه داشته باشید برای دیدن خروجی کامل شامل نمایه و فهرست مطالب، ابتدا دو بار این فایل را
%        را اجرا کرده، سپس با استفاده از خط فرمان، به مسیر پوشه جاری رفته و دستور 
% xindy -L persian -C utf8 -I xindy -M %.xdy -t %.glg -o %.gls %.glo
% xindy -L persian -C utf8 -I xindy -M %.xdy -t %.blg -o %.bls %.blo
% xindy -L persian -C utf8 -M texindy %.idx
%        را در خط فرمان اجرا کنید. سپس دو بار دیگر، این فایل را اجرا کنید. 
%        اگر قصد نوشتن پروژه کارشناسی را دارید، در خط زیر به جای msc، کلمه bsc و اگر قصد نوشتن رساله دکتری
%        را دارید، کلمه phd را قرار دهید. کلیه تنظیمات لازم، به طور خودکار، اعمال می‌شود.
\documentclass[msc]{AhmadMardi}
\csname@twosidetrue\endcsname
\RequirePackage[nottoc]{tocbibind}
\usepackage{tocbibind}
\usepackage{longtable}
\usepackage[xindy]{glossaries} 
\usepackage{makeidx}
\makeindex
\usepackage{xepersian} 
\settextfont[Scale=1.1]{XB Niloofar}
\defpersianfont\nastaliq[Scale=2]{IranNastaliq}
% چنانچه می‌خواهید اعداد در فرمول‌ها، انگلیسی باشد، خط زیر را غیرفعال کنید.
%\setdigitfont[Scale=1.1]{B Yas}
%%%
\usepackage{lipsum}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{proposition}{گزاره}[section]
\newtheorem{dfn}{تعریف}[section]
\theoremstyle{break}
\newtheorem{theorem}{قضیه}[section]
\newtheorem{lemma}{لم}[section]
\newtheorem{proofpart}{اثبات}
\makeatletter
\@addtoreset{proofpart}{theorem}
\makeatother
%%% List
%style=listgroup,nonumberlist
\newglossarystyle{mylistFa}{
\glossarystyle{list}
\renewenvironment{theglossary}{}{}
\renewcommand*{\glossaryheader}{}
\renewcommand*{\glsgroupheading}[1]{\section*{\glsgetgrouptitle{##1}} }
\renewcommand*{\glsgroupskip}{}
\renewcommand*{\glossaryentryfield}[5]     {\noindent\glstarget{##1}{##2}\dotfill \space ##3 \\}
\renewcommand*{\glossarysubentryfield}[6]{\glossaryentryfield{##2}{##3}{##4}{##5}{##6}}
}

\newglossarystyle{mylistEn}{
\glossarystyle{list}
\renewenvironment{theglossary}{}{}
\renewcommand*{\glossaryheader}{}
\renewcommand*{\glsgroupheading}[1]{\begin{LTR} \section*{\lr{\glsgetgrouptitle{##1}}} \end{LTR}}
\renewcommand*{\glsgroupskip}{}
\renewcommand*{\glossaryentryfield}[5]     {\noindent\glstarget{##1}{##3}\dotfill \space ##2 \\}
\renewcommand*{\glossarysubentryfield}[6]{\glossaryentryfield{##2}{##3}{##4}{##5}{##6}}
}

% تعریف دو نمونه واژه نامه
\newglossary[glg]{english}{gls}{glo}{واژه‌نامه انگلیسی به فارسی}
\newglossary[blg]{persian}{bls}{blo}{واژه‌نامه فارسی به انگلیسی}

\newcommand{\inpdic}[2]{
	\newglossaryentry{fa-#1}{type=persian,name={#1}, sort={#1},description={\lr{#2}}}\gls{fa-#1}\LTRfootnote{#2}
	\newglossaryentry{en-#1}{type=english,name={\lr{#2}}, sort={#2},description={#1}}\glsuseri{en-#1}
}

% توسط این دستور واژه مورد نظر در متن، هر دو واژه نامه  می آید.
\newcommand{\indic}[2]{
	\newglossaryentry{fa-#1}{type=persian,name={#1}, sort={#1},description={\lr{#2}}}\gls{fa-#1}
	\newglossaryentry{en-#1}{type=english,name={\lr{#2}}, sort={#2},description={#1}}\glsuseri{en-#1}
}
% توسط این دستور واژه مورد نظر فقط در هر دو واژه نامه  می آید.
\newcommand{\ingls}[2]{
	\newglossaryentry{fa-#1}{type=persian,name={#1}, sort={#1},description={\lr{#2}}}\glsuseri{fa-#1}
}
	%\newglossaryentry{en-#1}{type=english,name={\lr{#2}}, sort={#2},description={#1}}\glsuseri{en-#1}
%}

\newcommand{\inpgls}[2]{
	\newglossaryentry{fa-#1}{type=persian,name={#1}, sort={#1},description={\lr{#2}}}\gls{fa-#1}\LTRfootnote{#2}
}
\makeglossaries
\glsdisablehyper
%\inpdic{پ}{E} هم پا ورقی هم فارسی هم انگلیسی
%\inpgls{پ}{E} هم پا ورقی هم فارسی 
%\ingls{پ}{E} فقط در دیکشنری فارسی می آید.
%\indic{پ}{E} در واژه نامه فارسی و انگلیسی می‌آید
%index
%%%
\newcommand{\euler}{e}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\minimum}{minimum}
\DeclareMathOperator*{\maximum}{maximum}
\DeclareMathOperator*{\st}{sbject\,to}
\DeclareMathOperator*{\s.t.}{s.t.}
\DeclareMathOperator*{\VEC}{vec}
\DeclareMathOperator*{\diag}{diag}
\begin{document}
%-------shabih kardan codha b matlab--------
\lstset{language=Matlab,
   keywords={break,case,catch,continue,else,elseif,end,for,function,
      global,if,otherwise,persistent,return,switch,try,while},
   basicstyle=\ttfamily,
   keywordstyle=\color{blue},
   commentstyle=\color{dkgreen},
   stringstyle=\color{Plum},
   numbers=left,
   numberstyle=\tiny\color{gray2},
   stepnumber=1,
   numbersep=10pt,
   % backgroundcolor=\color{gray},
   tabsize=4,
   showspaces=false,
   showstringspaces=false}
%--------------flow chart---------
\tikzstyle{decision} = [diamond, draw=green, thick, fill=green!30, text width=5em, text badly centered, inner sep=1pt, rounded corners]
\tikzstyle{block} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=5cm,rounded corners, draw=black, fill=orange!30]
\tikzstyle{block2} = [ rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black,rounded corners, fill=red!30]
\tikzstyle{block1} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm,rounded corners, text centered, draw=black, fill=blue!30]
\tikzstyle{blockx}=[]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
minimum height=4em]
%--------
\vskip 20mm
\bibliographystyle{plain-fa}% such as plain-fa.bst
\bibliography{b} %such as MyReferences.bib
\end{document}