\documentclass[]{article}
%\documentclass[]{scrartcl}


% ============== PACKAGES ========================

\usepackage{geometry}
\usepackage{amsthm,amsmath,amssymb,amsfonts,bm,upgreek} % Math packages
%\usepackage{amsmath,amsfonts,amsthm} 
\usepackage[margin=0pt,font=small,labelfont={bf,normalsize},labelsep=space]{caption}%برای تنظیم : در کپشن ها 
\usepackage{fancyhdr} % Required for custom headers
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage{graphicx} % Required to insert images
\usepackage[T1]{fontenc}%requirednpackage for code 
\usepackage{beramono}%required package for code
\usepackage{listings} % Required for insertion of code
\usepackage{courier} % Required for the courier font
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{pdfpages}%برای اضافه کردن صفحات پی دی اف 

%پکیج های مربوط به اکسل 2 لاتک 

\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{bigstrut}
%------------------------------

% برای رنگی شدن لینک ها در فایل خروجی 
%\usepackage [pagebackref=true, colorlinks, linkcolor=blue, citecolor=magenta, urlcolor=cyan] {hyperref}
% چنانچه قصد پرینت گرفتن نوشته خود را دارید، خط بالا را غیرفعال و  از دستور زیر استفاده کنید. در ضمن pagebackref برای نشان دادن شماره صفحه ارجاعات مراجع در بخش bibliography است.
%\usepackage [pagebackref=false, colorlinks, linkcolor=black, citecolor=black, urlcolor=black] {hyperref}
\usepackage [pagebackref=true, colorlinks, linkcolor=black, citecolor=black, urlcolor=black] {hyperref}
%-----------------------------------------------------------
% پکیج تنظیمات زیرنویس ها 
%برای شروع زیرنویس ها در هر صفحه از شماره یک 
\usepackage[perpage]{footmisc}
% پکیج برای ایجاد فرورفتگی در پاراگراف های اول هر بخش و فصل
\usepackage{indentfirst} 
%\indent % دستور ایجاد فرورفتگی در هر پاراگراف 
%\noindent برای عدم تو رفتگی
%\parindent 8pt برای اندازه ی تو رفتگی 

% ==============END: PACKAGES ====================



%===========xepersian Initializing=====================
\usepackage{xepersian}
\settextfont[Scale=1]{XB Zar} %persian font
\setlatintextfont[Scale=1]{Times New Roman} % latin font
%\setdigitfont[Scale=1]{XB Niloofar}

\defpersianfont\mynewfont[Scale=1]{IranNastaliq}  % secend persian font 

%---------------------------------------------------------------
%																									تنظیم فاصله خطوط
%---------------------------------------------------------------
\linespread{1.5} % Line spacing
% {\mynewfont نوشته‌ای که قرار است با قلم متفاوت چاپ شود.}

%\defpersianfont\mynewfontenglish[Scale=1.1]{Times New Roman}
% =============================================



% ==============    MARGINES    =====================
%\topmargin=-0.45in
%\evensidemargin=0in
%\oddsidemargin=0in
%\textwidth=6.5in
%\textheight=9.0in
%\headsep=0.25in

%  OR
\geometry{%
	paper=a4paper, % Change to letterpaper for US letter
	inner=2.5cm, % Inner margin
	outer=3.8cm, % Outer margin
	bindingoffset=.5cm, % Binding offset
	top=1.5cm, % Top margin
	bottom=1.5cm, % Bottom margin
	%showframe, % Uncomment to show how the type block is set on the page
}

% ============== END:   MARGINES    ==================



%============== Set up the header and footer ============
%\pagestyle{fancy}
%\lhead{\hmwkAuthorName} % Top left header
%\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle} % Top center head
%\rhead{\firstxmark} % Top right header
%\lfoot{\lastxmark} % Bottom left footer
%\cfoot{} % Bottom center footer
%\rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}} % Bottom right footer
%\renewcommand\headrulewidth{0.4pt} % Size of the header rule
%\renewcommand\footrulewidth{0.4pt} % Size of the footer rule

%OR
%================ changes for this document 
\pagestyle{fancy}
\headheight = 40pt %header size
\fancyhead[L]{\thepage}
\fancyhead[c]{}
\fancyhead[r]{}
\fancyfoot{}
\renewcommand\headrulewidth{0 pt} % Size of the header rule
%================end of changes of this document



%\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers
%\fancyhead{} % No page header - if you want one, create it in the same way as the footers below
%\fancyfoot[L]{} % Empty left footer
%\fancyfoot[C]{} % Empty center footer
%\fancyfoot[R]{\thepage} % Page numbering for right footer
%\renewcommand{\headrulewidth}{0pt} % Remove header underlines
%\renewcommand{\footrulewidth}{0pt} % Remove footer underlines
%\setlength{\headheight}{13.6pt} % Customize the height of the header



%============== END: Set up the header and footer ========

%\setlength\parindent{0pt} % Removes all indentation from paragraphs

%----------------------------------------------------------------------------------------
%												تصحیح شماره گذاری فرمول ها و اشکال و جداول 
%----------------------------------------------------------------------------------------
%\numberwithin{equation}{chapter} 
% Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
%\numberwithin{equation}{section} 
% Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
%\numberwithin{figure}{section} 
% Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
%\numberwithin{table}{section} 
% Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)






% ===============Defining Julia language code box ===================

\lstdefinelanguage{Julia}%
{morekeywords={abstract,break,case,catch,const,continue,do,else,elseif,%
		end,export,false,for,function,immutable,import,importall,if,in,%
		macro,module,otherwise,quote,return,switch,true,try,type,typealias,%
		using,while},%
	sensitive=true,%
	%   alsoother={$},%
	morecomment=[l]\#,%
	morecomment=[n]{\#=}{=\#},%
	morestring=[s]{"}{"},%
	morestring=[m]{'}{'},%
}[keywords,comments,strings]%





%============= defining style for other codes ===============
% در صورتی که نیاز به ورود کد از سایر زبان ها بود بهتر است زبان به عنوان یک استایل تعریف شود و با یک دستور به این مجموعه اضافه شود.
\definecolor{DarkGreen}{rgb}{0.0,0.4,0.0} % Comment color
\definecolor{highlight}{RGB}{255,251,204} % Code highlight color

\lstdefinestyle{Style1}{ % Define a style for your code snippet, multiple definitions can be made if, for example, you wish to insert multiple code snippets using different programming languages into one document
	language=Perl, % Detects keywords, comments, strings, functions, etc for the language specified
	backgroundcolor=\color{highlight}, % Set the background color for the snippet - useful for highlighting
	basicstyle=\footnotesize\ttfamily, % The default font size and style of the code
	breakatwhitespace=false, % If true, only allows line breaks at white space
	breaklines=true, % Automatic line breaking (prevents code from protruding outside the box)
	captionpos=b, % Sets the caption position: b for bottom; t for top
	commentstyle=\usefont{T1}{pcr}{m}{sl}\color{DarkGreen}, % Style of comments within the code - dark green courier font
	deletekeywords={}, % If you want to delete any keywords from the current language separate them by commas
	%escapeinside={\%}, % This allows you to escape to LaTeX using the character in the bracket
	firstnumber=1, % Line numbers begin at line 1
	frame=single, % Frame around the code box, value can be: none, leftline, topline, bottomline, lines, single, shadowbox
	frameround=tttt, % Rounds the corners of the frame for the top left, top right, bottom left and bottom right positions
	keywordstyle=\color{Blue}\bf, % Functions are bold and blue
	morekeywords={}, % Add any functions no included by default here separated by commas
	numbers=left, % Location of line numbers, can take the values of: none, left, right
	numbersep=10pt, % Distance of line numbers from the code box
	numberstyle=\tiny\color{Gray}, % Style used for line numbers
	rulecolor=\color{black}, % Frame border color
	showstringspaces=false, % Don't put marks in string spaces
	showtabs=false, % Display tabs in the code as lines
	stepnumber=1, % The step distance between line numbers, i.e. how often will lines be numbered
	stringstyle=\color{Purple}, % Strings are purple
	tabsize=2, % Number of spaces per tab in the code
}


\lstdefinestyle{Style2}{ 
	language         = Julia,
	basicstyle       =\footnotesize\ttfamily,
	keywordstyle     = \bfseries\color{blue},
	stringstyle      = \color{magenta},
	commentstyle     = \color{ForestGreen},
	showstringspaces = false,
	%added later
	breaklines=true, % Automatic line breaking (prevents code from protruding outside the box)
	frame=single, % Single frame around code
	numbers=left, % Line numbers on left
	firstnumber=1, % Line numbers start with line 1
	numberstyle=\tiny\color{Blue}, % Line numbers are blue and small
	stepnumber=1 % Line numbers go in steps of 5
	%end added later
}


% Create a command to cleanly insert a snippet with the style above anywhere in the document
\newcommand{\insertcode}[2]{\begin{itemize}\item[]\lstinputlisting[caption=#2,label=#1,style=Style1]{#1}\end{itemize}} 
% The first argument is the script location/filename and the second is a caption for the listing
\newcommand{\insertjuliacode}[2]{\begin{itemize}\item[]\lstinputlisting[caption=#2,label=#1,style=Style2]{#1}\end{itemize}} 
%----------------------------------------------------------------------------------------

	
%---------------------مثال دستور درج کد در متن با استفاده از فایل کد  -------------------------------------------
	
%	\insertcode{"Scripts/example.pl"}{Nena would be proud.} % The first argument is the script location/filename and the second is a caption for the listing
%مثال درج کد در متن با استفاده از دستور -------------------------------------------------------------------------
%

%\begin{lstlisting}	

% some codes

%\end{lstlisting}

%-------------------------------------------------------------------------------------------------------------------------
%===================END Defining language code box ====================================



%opening

% ===============================================
%پانویس فارسی و انگلیسی
%
%زیرنویس  { }footnote\ 
%زیرنویس فارسی: { }RTLfootnote\
%زیرنویس انگلیسی: { }LTRfootnote\
%================================================
%دقت کنید که به صورت پیش فرض اعداد و ارقام به صورت فارسی در فرمول ها در لاتک نوشته می شود، اگر بخواهد اعداد و ارقام به صورت انگلیسی در فرمول ها ظاهر شوند، کافی است دستور زیر را بنویسید:
%\DefaultMathsDigits
%================================================


\begin{document}
	
محل قرارگیری متن 

\end{document}
%*بِســمِ اللهِ الرَّحـمنِ الرَّحـیمِ*
%حَافِظُوا عَلَى الصَّلَوَاتِ وَالصَّلَاةِ الْوُسْطَىٰ وَقُومُوا لِلَّهِ قَانِتِينَ
%بقره / 238