[XeTeX] Xetex sample guide for farsi
VAFA KHALIGHI
vafa.khalighi at students.mq.edu.au
Thu Apr 24 06:54:43 CEST 2008
I am afraid there is no guide for typesetting just persian in XeTeX. but I
can explain everything to you here.
Ok, the version of XeTeX which is in TeXlive2007 is 0.996, from my
experience it is better to compile the 0.997 version for typesetting Persian
alternatively you can uninstall TeXlive2007 and use MiKTeX2.7, this only
applies if you are a windows fan.
ok, then you need to download a TeX editor, the best from my experience is
TeXmaker, you can get it from
http://www.xm1math.net/texmaker/download.html
after installing it and making sure you have a version of TeX system and a
pdf reader installed on your computer, we are going to do the first step
which is setting the editor.
1- click on options, then click on Configure TeXmaker and then just open the
folder that corresponds to pdflatex command and go to your binary directory
and choose xelatex. then open the folder that corresponds to your pdf reader
and choose your favourite pdf reader. then go to Quick bulid and choose
PDFlatex+view pdf. then click on editor and choose utf8 for Editor Font
Encoding. now click ok.
Ok make a folder anywhere that you like and then open TeXmaker and put these
commands in:
%%%%%%%%%%%%%%%
\makeatletter
\renewcommand{\thepage}{\textfarsi{\the\c at page}}
\renewcommand{\thesection}{\textfarsi{\the\c at section}}
\renewcommand{\thesubsection}{\textfarsi{\the\c at section
\textroman{-}\the\c at subsection}}
\renewcommand{\thepart}{\textfarsi{\the\c at 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{\refname}{\textfarsi{مراجع}}%
\renewcommand{\abstractname}{\textfarsi{چکیده}}%
}{}
\@ifclassloaded{report}{%
\renewcommand{\bibname}{\textfarsi{کتابنامه}}%
\renewcommand{\abstractname}{\textfarsi{چکیده}}%
\renewcommand{\chaptername}{\textfarsi{فصل}}%
\renewcommand{\partname}{\textfarsi{بخش}}%
}{}
\@ifclassloaded{book}{%
\renewcommand{\bibname}{\textfarsi{کتابنامه}}%
\renewcommand{\chaptername}{\textfarsi{فصل}}%
\renewcommand{\partname}{\textfarsi{بخش}}%
}{}
%\renewcommand{\prefacename}{\textfarsi{پیشگفتار}}%
%To convert the MILADI date to SHAMSI date
\InputIfFileExists{ftoday.sty}{%
\message{Loading the definitions for the Jalali calendar}}{%
\errhelp{I can't find the ftoday.sty file for the Jalali calendar}%
\errmessage{Since I do not know what the Jalali calendar is^^J
I can't typeset the Farsi date.^^J
I stop here, while you get a suitable ftoday.sty file}\@@end
}
%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 at xt@\hsize{\hfil\box\@Arabitempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
%The footnote-rule from right to left, taken from farsitex
\def\r at fn{%
\hbox to \columnwidth
{\beginR \vbox{\kern -3\p@
\hrule width .4\columnwidth \kern2.6\p@}\hfil\endR}}
\def\footnoterule{\r at fn}
%For Right-to-Left two column command, I guess taken from rlbabel
\let\@old at outputdblcol\@outputdblcol
\newcommand{\rl at outputdblcol}{%
\if at firstcolumn
\global \@firstcolumnfalse
\global \setbox\@leftcolumn \box\@outputbox
\else
\global \@firstcolumntrue
\setbox\@outputbox \vbox {\hb at xt@\textwidth {%
\hskip\columnwidth%
\hfil\vrule\@width\columnseprule\hfil
\hb at xt@\columnwidth {%
\box\@leftcolumn \hss}%
\hb at xt@\columnwidth {%
\hskip-\textwidth%
\box\@outputbox \hss}%
\hskip\columnsep%
\hskip\columnwidth}}%
\@combinedblfloats
\@outputpage
\begingroup
\@dblfloatplacement
\@startdblcolumn
\@whilesw\if at fcolmade \fi
{\@outputpage
\@startdblcolumn}%
\endgroup
\fi}
\newcommand{\rldblcolumn}{\renewcommand{\@outputdblcol}{\rl at outputdblcol}}
\newcommand{\lrdblcolumn}{\renewcommand{\@outputdblcol}{\@old at outputdblcol}}
%set the default direction of the twocolumn texts to Right-to-Left
\rldblcolumn
%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\mathfnumber{
\XeTeXmathcode`0="7 "4 "06F0%
\XeTeXmathcode`1="7 "4 "06F1%
\XeTeXmathcode`2="7 "4 "06F2%
\XeTeXmathcode`3="7 "4 "06F3%
\XeTeXmathcode`4="7 "4 "06F4%
\XeTeXmathcode`5="7 "4 "06F5%
\XeTeXmathcode`6="7 "4 "06F6%
\XeTeXmathcode`7="7 "4 "06F7%
\XeTeXmathcode`8="7 "4 "06F8%
\XeTeXmathcode`9="7 "4 "06F9%
\XeTeXmathcode`.="7 "4 "066B%decimal point
}
\XeTeXmathcode`٫="7 "4 "066B%decimal point
\XeTeXmathcode`۰="7 "4 "06F0%
\XeTeXmathcode`۱="7 "4 "06F1%
\XeTeXmathcode`۲="7 "4 "06F2%
\XeTeXmathcode`۳="7 "4 "06F3%
\XeTeXmathcode`۴="7 "4 "06F4%
\XeTeXmathcode`۵="7 "4 "06F5%
\XeTeXmathcode`۶="7 "4 "06F6%
\XeTeXmathcode`۷="7 "4 "06F7%
\XeTeXmathcode`۸="7 "4 "06F8%
\XeTeXmathcode`۹="7 "4 "06F9%
%to resolve a problem we encounter when using power
%or index in math formula
\makeatletter\def\arabtex at codes{}\makeatother
%a command to put a footnote from left to right
%while in a right to left context
\newcommand{\lrfootnote}[1]{%
\bgroup% To make the scope of the change local
\footnotemark%
\renewcommand{\thefootnote}{\arabic{footnote}}%
\unsetRL%
\footnotetext{#1}%
\egroup
}
\makeatother
%%%%%%%%%%%%%
and then save it as farsixetex.tex to your folder.
thn open another widow in TeXmaker and copy these commands
%%%%%%%%%%%%%%%%%
\newif\ifFT at leap \newif\ifFT at kabiseh
\newcount\FT at i \newcount\FT at y \newcount\FT at m \newcount\FT at d
\newcount\FT at latini \newcount\FT at farsii
\newcount\FT at latinii \newcount\FT at farsiii
\newcount\FT at latiniii \newcount\FT at farsiiii
\newcount\FT at latiniv \newcount\FT at farsiiv
\newcount\FT at latinv \newcount\FT at farsiv
\newcount\FT at latinvi \newcount\FT at farsivi
\newcount\FT at latinvii \newcount\FT at farsivii
\newcount\FT at latinviii \newcount\FT at farsiviii
\newcount\FT at latinix \newcount\FT at farsiix
\newcount\FT at latinx \newcount\FT at farsix
\newcount\FT at latinxi \newcount\FT at farsixi
\newcount\FT at latinxii \newcount\FT at farsixii
\newcount\FT at farsixiii
\newcount\FT at temp
\newcount\FT at temptwo
\newcount\FT at tempthree
\newcount\FT at yModHundred
\newcount\FT at thirtytwo
\newcount\FT at dn
\newcount\FT at sn
\newcount\FT at mminusone
\def\ftoday{%
\FT at y=\year \FT at m=\month \FT at d=\day
%
\FT at temp=\FT at y
\divide\FT at temp by 100\relax
\multiply\FT at temp by 100\relax
\FT at yModHundred=\FT at y
\advance\FT at yModHundred by -\FT at temp\relax
%
\ifodd\FT at yModHundred
\FT at leapfalse
\else
\FT at temp=\FT at yModHundred
\divide\FT at temp by 2\relax
\ifodd\FT at temp\FT at leapfalse
\else
\ifnum\FT at yModHundred=0%
\FT at temp=\FT at y
\divide\FT at temp by 400\relax
\multiply\FT at temp by 400\relax
\ifnum\FT at y=\FT at temp\FT at leaptrue\else\FT at leapfalse\fi
\else\FT at leaptrue
\fi
\fi
\fi
%
\FT at latini=31\relax
\ifFT at leap
\FT at latinii = 29\relax
\else
\FT at latinii = 28\relax
\fi
\FT at latiniii = 31\relax
\FT at latiniv = 30\relax
\FT at latinv = 31\relax
\FT at latinvi = 30\relax
\FT at latinvii = 31\relax
\FT at latinviii = 31\relax
\FT at latinix = 30\relax
\FT at latinx = 31\relax
\FT at latinxi = 30\relax
\FT at latinxii = 31\relax
%
\FT at thirtytwo=32\relax
%
\FT at temp=\FT at y
\advance\FT at temp by -17\relax
\FT at temptwo=\FT at temp
\divide\FT at temptwo by 33\relax
\multiply\FT at temptwo by 33\relax
\advance\FT at temp by -\FT at temptwo
\ifnum\FT at temp=\FT at thirtytwo\FT at kabisehfalse
\else
\FT at temptwo=\FT at temp
\divide\FT at temptwo by 4\relax
\multiply\FT at temptwo by 4\relax
\advance\FT at temp by -\FT at temptwo
\ifnum\FT at temp=\z@\FT at kabisehtrue\else\FT at 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 at tempthree=\FT at y % Number of Leap years
\advance\FT at tempthree by -1
\FT at temp=\FT at tempthree % T := (MY-1) div 4
\divide\FT at temp by 4\relax
\FT at temptwo=\FT at tempthree % T := T - ((MY-1) div 100)
\divide\FT at temptwo by 100\relax
\advance\FT at temp by -\FT at temptwo
\FT at temptwo=\FT at tempthree % T := T + ((MY-1) div 400)
\divide\FT at temptwo by 400\relax
\advance\FT at temp by \FT at temptwo
\advance\FT at tempthree by -611 % Number of Kabise years
\FT at temptwo=\FT at tempthree % T := T - ((SY+10) div 33) * 8
\divide\FT at temptwo by 33\relax
\multiply\FT at temptwo by 8\relax
\advance\FT at temp by -\FT at temptwo
\FT at temptwo=\FT at tempthree %
\divide\FT at temptwo by 33\relax
\multiply\FT at temptwo by 33\relax
\advance\FT at tempthree by -\FT at temptwo
\ifnum\FT at tempthree=32\advance\FT at temp by 1\fi % if (SY+10) mod 33=32 then
Inc(T);
\divide\FT at tempthree by 4\relax % T := T - ((SY+10) mod 33) div 4
\advance\FT at temp by -\FT at tempthree
\advance\FT at temp by -137 % T := T - 137 Adjust the value
\FT at farsii=31
\advance\FT at farsii by -\FT at temp % now 31 - T is the farsii
%
\FT at farsiii = 30\relax
\ifFT at kabiseh
\FT at farsiiii = 30\relax
\else
\FT at farsiiii = 29\relax
\fi
\FT at farsiiv = 31\relax
\FT at farsiv = 31\relax
\FT at farsivi = 31\relax
\FT at farsivii = 31\relax
\FT at farsiviii= 31\relax
\FT at farsiix = 31\relax
\FT at farsix = 30\relax
\FT at farsixi = 30\relax
\FT at farsixii = 30\relax
\FT at farsixiii= 30\relax
%
\FT at dn= 0\relax
\FT at sn= 0\relax
\FT at mminusone=\FT at m
\advance\FT at mminusone by -1\relax
%
\FT at i=0\relax
\ifnum\FT at i < \FT at mminusone
\loop
\advance \FT at i by 1\relax
\advance\FT at dn by \csname FT at latin\romannumeral\the\FT at i\endcsname
\ifnum\FT at i<\FT at mminusone \repeat
\fi
\advance \FT at dn by \FT at d
%
\FT at i=1\relax
\FT at sn = \FT at farsii
\ifnum \FT at sn<\FT at dn
\loop
\advance \FT at i by 1\relax
\advance\FT at sn by \csname FT at farsi\romannumeral\the\FT at i\endcsname
\ifnum \FT at sn<\FT at dn \repeat
\fi
\ifnum \FT at i < 4
\FT at m = 9 \advance\FT at m by \FT at i
\advance \FT at y by -622\relax
\else
\FT at m = \FT at i \advance \FT at m by -3\relax
\advance \FT at y by -621\relax
\fi
\advance\FT at sn by -\csname FT at farsi\romannumeral\the\FT at i%
\endcsname
\ifnum\FT at i = 1
\FT at d = \FT at dn \advance \FT at d by 30 \advance\FT at d by -\FT at farsii
\else
\FT at d = \FT at dn \advance \FT at d by -\FT at sn
\fi
\beginL\number\FT at d\endL\space%
%Changedc from here YJ
\farsimonth{\FT at m}\space\beginL\number\FT at y\endL%
}
% added \farsimonth YJ
\def\farsimonth#1{\ifcase#1\or فروردین\or
اردیبهشت\or
خرداد\or تیر\or
مرداد\or
شهریور\or مهر\or
آبان\or آذر\or
دی\or بهمن\or
اسفند\fi}
\endinput
%%%%%%%%%%%%%%
and save it as ftoday.sty
then open another window in TeXmaker and copy these commands
%%%%%%%%%%%
\documentclass{article}
\usepackage{fontspec}\usepackage{xunicode}
\usepackage{arabxetex}
\usepackage{setspace}
\usepackage{makeidx}
\makeindex
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot[RE,LO]{\small\farsifont\beginR صفحهٔ \thepage\endR}
\fancyfoot[LE,RO]{\small\farsifont\beginR آهنگ عشق ۱۶۴ بدیع\endR}
\fancyfoot[C]{\small\farsifont\beginR شمارهٔ ۱۶۱\endR}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0.4pt}
\setromanfont[Mapping=tex-text]{Times New Roman}
\newfontinstance\farsifont[Script=Arabic,Scale=1.2,WordSpace=1]{Roya}
\newfontinstance\arabicfont[Script=Arabic,Scale=1.2,WordSpace=1]{Roya}
\input{farsixetex.tex}
\def\theenumii{\abjad{\arabic{enumii}}}
%comment the following line at the end
%this is to be used only for the index to work correctly
%\makeatletter\renewcommand{\thepage}{\the\c at page}\makeatother
\onehalfspacing
\begin{document}
\mathfnumber
\begin{farsi}
%your Farsi inputs
\end{farsi}
\end{document}
%%%%%%%%%%%%
ok whatever you want to write in Farsi should be between \begin{farsi} and
\end{farsi}, if you want to write a an english word inside that environment
use \textroman{word} and for arabic use \textarab{العربی} and you also can
have \begin{arab} and \end{arab}. for making a section you gotta use
something like
\section{\farsifont این یک قسمت است} inside The Farsi environment.
Before doing anything you also should install farsiweb projects, they come
with my linux distribution.
--
PSTricks
http://pstricks.wordpress.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/xetex/attachments/20080424/186a0b3d/attachment-0001.html
More information about the XeTeX
mailing list