summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/bidi/bidi-manual.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/bidi/bidi-manual.tex')
-rw-r--r--Master/texmf-dist/doc/latex/bidi/bidi-manual.tex856
1 files changed, 856 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/bidi/bidi-manual.tex b/Master/texmf-dist/doc/latex/bidi/bidi-manual.tex
new file mode 100644
index 00000000000..3a86ebc837c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/bidi/bidi-manual.tex
@@ -0,0 +1,856 @@
+\documentclass{article}
+\usepackage{calc}
+\usepackage{pifont}
+\usepackage{bbding}
+\usepackage{bidicode}
+\usepackage{fontspec}
+\definecolor{bidiblue}{rgb}{0.1,0.2,0.8}
+\usepackage[numbered]{hypdoc}
+\hypersetup{pdftitle={The \textsf{bidi} Package (Support for bidirectional typesetting in plain \TeX{} and \LaTeXe)},pdfauthor={Vafa Khalighi <vafakh@me.com>},linkcolor=bidiblue,urlcolor=bidiblue,citecolor=bidiblue}
+\setlength\columnseprule{.4pt}
+\newcommand\XeTeX{Xe\TeX}
+\newcommand\XeLaTeX{Xe\LaTeX}
+\makeatletter
+\pdfstringdefDisableCommands{%
+\renewcommand\Lcs[1]{\textbackslash#1}
+}
+\renewcommand\tableofcontents{\relax
+ \begin{multicols}{2}[\section*{\contentsname}]\small
+ \@starttoc{toc}\relax
+ \end{multicols}}
+\makeatother
+\newcounter{local}
+\renewcommand\theenumi{\protect\setcounter{local}%
+ {201+\the\value{enumi}}\protect\ding{\value{local}}}
+\renewcommand\labelenumi{\theenumi}
+\renewcommand\labelitemi{\HandRight}
+\renewcommand\labelitemii{\HandRightUp}
+\renewcommand\labelitemiii{\HandCuffRight}
+\renewcommand\labelitemiv{\HandPencilLeft}
+ \title{The \textsf{bidi} Package\\[10pt]
+ \includegraphics[width=0.5\textwidth]{bidi-logo}\\[10pt]
+ Support for bidirectional typesetting in plain \TeX{} and \LaTeXe}
+ \author{Vafa Khalighi\\
+ \url{vafakh@me.com}}
+ \date{\today\qquad Version 13.6}
+\begin{document}
+\maketitle
+ \tableofcontents
+\section*{Introduction}
+\textsf{bidi} provides a convenient interface for typesetting bidirectional texts in plain \TeX\ and \LaTeX.
+
+The \textsf{bidi} package at the moment only works with \XeTeX\ engine, but we will support other \TeX\ engines as well in the future.
+\subsection*{\textsf{bidi} Info On The Terminal and In The Log File}
+If you use \textsf{bidi} package to write any input \TeX\ document, and then run \texttt{xelatex} on your document, \textsf{bidi} writes some information about itself to the terminal and to the log file. The information is something like:
+\begin{lstlisting}[backgroundcolor=\color{blue!20},numbers=none,frame=none,framexleftmargin=1mm]
+bidi package (Support for bidirectional typesetting in plain TeX and LaTeX)
+Description: A convenient interface for typesetting bidirectional texts
+in plain TeX and LaTeX. The package includes adaptations for use
+with many other commonly-used packages.
+Copyright (c) 2009-2013 Vafa Khalighi
+v13.6, 2013/09/06
+License: LaTeX Project Public License, version 1.3c or higher (your choice)
+Location on CTAN: /macros/latex/contrib/bidi
+\end{lstlisting}
+\part{\LaTeX\ Manual}
+\section{Basics}
+\subsection{Loading The Package}
+You can load the package in the ordinary way;
+\begin{BDef}
+\Lcs{usepackage}\OptArgs\Largb{bidi}
+\end{BDef}
+Where \texttt{options} of the package are explained later in \autoref{options}.
+
+When loading the package, it is important to know that:
+\begin{enumerate}
+\item \textsf{bidi} should be the last package that you load, because otherwise you are certainly going to overwrite \textsf{bidi}'s definitions and consequently, you will not get the expected output.
+\item In fact, \textsf{bidi} makes sure that some specific packages are loaded before \textsf{bidi}; these are those packages that \textsf{bidi} modifies them for bidirectional typesetting.
+
+If you load \textsf{bidi} before any of these packages, then you will get an error saying that you should load \textsf{bidi} as your last package.
+
+For instance, consider the following minimal example:
+\begin{lstlisting}
+\documentclass{minimal}
+\usepackage{bidi}
+\usepackage{graphicx}
+\begin{document}
+This is just a test.
+\end{document}
+\end{lstlisting}
+Where \textsf{graphicx} is loaded after \textsf{bidi}. If you run \texttt{xelatex} on this document, you will get an error which looks like this:
+\begin{lstlisting}[backgroundcolor=\color{blue!20},numbers=none,frame=none,framexleftmargin=1mm]
+! Package bidi Error: Oops! you have loaded package graphicx after bidi package. Please load package graphicx before bidi package, and then try to run xelatex on your document again.
+
+See the bidi package documentation for explanation.
+Type H <return> for immediate help.
+ ...
+
+l.4 \begin{document}
+
+?
+
+\end{lstlisting}
+\end{enumerate}
+\subsection{\textsf{bidi}'s Symbol}
+ As you may know lion symbolizes \TeX{} but lion does not symbolizes \textsf{bidi}. \textbf{Simorgh}\footnote{\textbf{Simorgh} is an Iranian benevolent, mythical flying creature which has been shown on the titlepage of this documentation. For more details see \url{http://en.wikipedia.org/wiki/Simurgh}} (shown on the first page of this documentation) symbolizes \textsf{bidi}.
+\subsection{Commands for Version number, and Date of The Package}
+\begin{BDef}
+\Lcs{bidiversion}\quad\Lcs{bididate}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{bidiversion} gives the current version of the package.
+\item \Lcs{bididate} gives the current date of the package.
+\end{itemize}
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\begin{document}
+This is typeset by \textsf{bidi} package, \bidiversion, \bididate.
+\end{document}
+\end{lstlisting}
+\subsection{Turning TeX-{-}XeT features on and off}
+The bidirectional typesetting in \XeTeX{} is based on TeX-{-}XeT algorithm and \textsf{bidi} package automatically turns the feature on for typesetting bidirectional texts. As the internal data structures built by TeX-{-}XeT differ from those built by \TeX, the typesetting of a document by TeX-{-}XeT may therefore differ from that performed by \TeX. So you may notice that some packages behave differently when TeX-{-}XeT feature is on and you may want to turn the feature off for a part of the text so that you get the default behaviour of original \TeX. Two commands are provided for this purpose:
+\begin{BDef}
+\Lcs{TeXXeTOn}\quad\Lcs{TeXXeTOff}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{TeXXeTOn} turns TeX-{-}XeT feature on, which is active by default when \textsf{bidi} package is loaded.
+\item \Lcs{TeXXeTOff} turns TeX-{-}XeT feature off.
+\end{itemize}
+\subsection{Options of The Package\label{options}}
+There are three options, namely \texttt{RTLdocument} and \texttt{rldocument}, which are essentialy equivalent. If you pass any of these options to the package, you will be typesetting a document containing mainly RTL texts with some LTR texts. These options activate \Lcs{setRTL} (explained in \autoref{PSC}), \Lcs{RTLdblcol} (explained in \autoref{twocolumn}) and \Lcs{autofootnoterule} (explained in \autoref{footnoterule}).
+
+It is clear that if you do not pass any of these options to the package, you will be typesetting a document containing mainly LTR texts with some RTL texts.
+
+There is also \texttt{extrafootnotefeatures} option that allows footnotes to be typeset in different formats:
+\begin{BDef}
+\Lcs{normalfootnotes}\\
+\Lcs{twocolumnfootnotes}\quad\Lcs{threecolumnfootnotes}\quad\Lcs{fourcolumnfootnotes}\\
+\Lcs{fivecolumnfootnotes}\quad\Lcs{sixcolumnfootnotes}\quad\Lcs{sevencolumnfootnotes}\\
+\Lcs{eightcolumnfootnotes}\quad\Lcs{ninecolumnfootnotes}\quad\Lcs{tencolumnfootnotes}\\
+\Lcs{RTLcolumnfootnotes}\quad\Lcs{LTRcolumnfootnotes}\\
+\Lcs{paragraphfootnotes}\\
+\Lcs{setLTRparagraphfootnotes}\quad\Lcs{setRTLparagraphfootnotes}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{normalfootnotes} typesets footnotes in Standard \LaTeX{} format.
+\item \Lcs{twocolumnfootnotes} to \Lcs{tencolumnfootnotes}, typeset footnotes in two-columns to ten-columns, respectively.
+\item \Lcs{RTLcolumnfootnotes} typesets footnotes columns RTL (first column on the RHS and each next column to the left of the previous column) and \Lcs{LTRcolumnfootnotes} typesets footnotes columns LTR (first column on the LHS and each next column to the right of the previous column). \Lcs{LTRcolumnfootnotes} is active by default.
+\item \Lcs{paragraphfootnotes} typesets footnotes in paragraph format.
+\item \Lcs{setLTRparagraphfootnotes} makes footnotes run from left to right. This comand is active by default.
+\item \Lcs{setRTLparagraphfootnotes} makes footnotes run from right to left.
+\end{itemize}
+ Please note that when using \texttt{extrafootnotefeatures} option, the footnote rule will be as wide as the text width and \Lcs{autofootnoterule}, \Lcs{rightfootnoterule}, \Lcs{leftfootnoterule}, and \Lcs{textwidthfootnoterule} commands have no effects.
+
+
+
+ Please also note that if you redefine \Lcs{baselinestretch} command or change the value of \Lcs{baselineskip} primitive before \Lcs{paragraphfootnotes} command, then you may get Arithmetic Overflow error. You should change these after using \Lcs{paragraphfootnotes} command.
+\subsection{Paragraph Switching Commands\label{PSC}}
+\begin{BDef}
+\Lcs{setLTR}\quad\Lcs{setLR}\quad\Lcs{unsetRL}\quad\Lcs{unsetRTL}\\
+\Lcs{setRTL}\quad\Lcs{setRL}\quad\Lcs{unsetLTR}
+\end{BDef}
+\begin{itemize}
+\item With any of the commands in the first row, you can typeset LTR paragraphs.
+\item With any of the commands in the second row, you can typeset RTL paragraphs.
+\end{itemize}
+\begin{lstlisting}[morekeywords={newfontfamily,Parsifont}]
+\documentclass{article}
+\usepackage{fontspec}
+\newfontfamily\Parsifont[Script=Arabic]{Yas}
+\usepackage{bidi}
+\begin{document}
+\setRTL%
+Anyone who reads Old and Middle English literary texts will be
+ familiar with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+
+\setLTR% Notice the blank line before \setLTR
+Anyone who reads Old and Middle English literary texts will be
+ familiar with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\end{document}
+\end{lstlisting}
+\subsection{Pargraph Switching Environments}
+\begin{BDef}
+\LBEG{LTR}\quad\Larga{text}\quad\LEND{LTR}\\
+\LBEG{RTL}\quad\Larga{text}\quad\LEND{RTL}
+\end{BDef}
+\begin{itemize}
+\item With \texttt{LTR} environment, you can typeset LTR paragraphs.
+\item With \texttt{RTL} environment, you can typeset RTL paragraphs.
+\end{itemize}
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\begin{document}
+\begin{RTL}
+Anyone who reads Old and Middle English literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\begin{LTR}
+Anyone who reads Old and Middle English literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\end{LTR}
+And we are still typesetting RTL.
+\end{RTL}
+\end{document}
+\end{lstlisting}
+\subsection{Typesetting Short LTR and RTL Texts}
+\begin{BDef}
+\Lcs{LRE}\Largb{\Larga{text}}\quad\Lcs{LR}\Largb{\Larga{text}}\\
+\Lcs{RLE}\Largb{\Larga{text}}\quad\Lcs{RL}\Largb{\Larga{text}}
+\end{BDef}
+\begin{itemize}
+\item With any of the commands in the first row, you can typeset short LTR text inside RTL paragraphs.
+\item With any of the commands in the second row, you can typeset short RTL text inside LTR paragraphs.
+\end{itemize}
+\begin{lstlisting}
+\begin{document}
+\begin{RTL}
+Anyone who reads Old and Middle English \LRE{Short LTR text} literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\begin{LTR}
+Anyone who reads Old and Middle English \RLE{Short RTL text} literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\end{LTR}
+\end{RTL}
+\end{document}
+\end{lstlisting}
+\subsection{Footnotes}
+\begin{BDef}
+\Lcs{footnote}\OptArg{num}\Largb{\Larga{text}}\quad\Lcs{LTRfootnote}\OptArg{num}\Largb{\Larga{text}}\quad\Lcs{RTLfootnote}\OptArg{num}\Largb{\Larga{text}}\\
+\Lcs{setfootnoteRL}\quad\Lcs{setfootnoteLR}\quad\Lcs{unsetfootnoteRL}\\
+\Lcs{thanks}\Largb{\Larga{text}}\quad\Lcs{LTRthanks}\Largb{\Larga{text}}\quad\Lcs{RTLthanks}\Largb{\Larga{text}}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{footnote} in RTL mode produces an RTL footnote while in LTR mode it produces an LTR footnote.
+\item \Lcs{LTRfootnote} will always produce an LTR footnote, independent on the current mode.
+\item \Lcs{RTLfootnote} will always produce an RTL footnote, independent on the current mode.
+\item Specifying a \Lcs{setfootnoteRL} command anywhere will make \Lcs{footnote} produce an RTL footnote.
+\item Specifying either a \Lcs{setfootnoteLR} or an \Lcs{unsetfootnoteRL} command anywhere will make \Lcs{footnote} produce an LTR footnote.
+\item \Lcs{thanks} (to be used only inside \Lcs{author} or \Lcs{title} argument) in RTL mode produces an RTL footnote while in LTR mode it produces an LTR footnote.
+\item \Lcs{LTRthanks} (to be used only inside \Lcs{author} or \Lcs{title} argument) will always produce an LTR footnote, independent on the current mode.
+\item \Lcs{RTLthanks} (to be used only inside \Lcs{author} or \Lcs{title} argument) will always produce an RTL footnote, independent on the current mode.
+\end{itemize}
+\begin{BDef}
+\Lcs{footnotetext}\OptArg{num}\Largb{\Larga{text}}\quad\Lcs{LTRfootnotetext}\OptArg{num}\Largb{\Larga{text}}\\
+\Lcs{RTLfootnotetext}\OptArg{num}\Largb{\Larga{text}}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{footnotetext} used in conjunction with \Lcs{footnotemark}, in RTL mode produces an RTL footnote while in LTR mode it produces an LTR footnote.
+\item \Lcs{LTRfootnotetext} used in conjunction with \Lcs{footnotemark}, will always produce an LTR footnote, independent on the current mode.
+\item \Lcs{RTLfootnotetext} used in conjunction with \Lcs{footnotemark}, will always produce an RTL footnote, independent on the current mode.
+\end{itemize}
+\subsubsection{Footnote Rule\label{footnoterule}}
+The behavior of footnote rules can also be controlled.
+\begin{BDef}
+\Lcs{autofootnoterule}\quad\Lcs{rightfootnoterule}\quad\Lcs{leftfootnoterule}\\
+\Lcs{LRfootnoterule}\quad\Lcs{textwidthfootnoterule}\quad\Lcs{SplitFootnoteRule}\\
+\Lcs{debugfootnotedirection}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{autofootnoterule} will draw the footnote rule right or left aligned based on the direction of the first footnote following the rule (i.e., put in the current page).
+\item \Lcs{rightfootnoterule} will put footnote rule on the right-hand side.
+\item \Lcs{leftfootnoterule} or \Lcs{LRfootnoterule} will put footnote rule on the left-hand side.
+\item \Lcs{textwidthfootnoterule} will draw the footnote rule with a width equal to \Lcs{textwidth}.
+\item \Lcs{SplitFootnoteRule} puts a full-width rule above the split-off part of a split footnote.
+\item \Lcs{debugfootnotedirection} writes the direction of the first footnote on each page, in the log file.
+\end{itemize}
+\subsection{Two Column Typesetting\label{twocolumn}}
+\begin{BDef}
+\Lcs{RTLdblcol}\quad\Lcs{LTRdblcol}
+\end{BDef}
+If you pass the \texttt{twocolumn} option to the class file and if the main direction of the document is RTL, then you get RTL two column and if the main direction of the document is LTR, then you get LTR two column. In addition, \Lcs{RTLdblcol} allows you to have RTL two column typesetting and \Lcs{LTRdblcol} allows you to have LTR two column typesetting as the options of the class file.
+
+Also please note that in \texttt{twocolumn} documents, the width of the \Lcs{footnoterule} will be equal to \Lcs{columnwidth} no matter which footnote-rule commands you use; indeed, in \texttt{twocolumn} documents only \Lcs{textwidthfootnoterule} is active and other footnote-rule commands will not be effective.
+\subsection{RTL cases}
+\marginpar{\Lcs{RTLcases} command was previously known as \Lcs{rcases} command but since there was a clash with \textsf{mathtools} package (mathtools defines \textsf{rcases} environment), we had to rename \Lcs{rcases} command to \Lcs{RTLcases} command.}
+\begin{BDef}
+\Lcs{RTLcases}\Largb{\Lcs{text}\Largb{\Larga{brach1}}\Lcs{cr}\Lcs{text}\Largb{\Larga{brach2}}\Lcs{cr}%
+\Lcs{text}\Largb{\Larga{brach3}}\ldots}\\
+\Lcs{text}\Largb{\Larga{main}}
+\end{BDef}
+\Lcs{RTLcases} is defined in bidi for typesetting RTL cases. \Lcs{text} is defined in \textsf{amsmath} package, so this means that you need to load \textsf{amsmath} package too.
+\begin{lstlisting}[morekeywords={RTLcases,text}]
+\documentclass{article}
+\usepackage{amsmath}
+\usepackage{bidi}
+\begin{document}
+\setRTL
+\[\RTLcases{\text{men}\cr\text{women}}
+\text{Humans Beings}
+\]
+\end{document}
+\end{lstlisting}
+\subsection{Typesetting Logos}
+\begin{BDef}
+\Lcs{XeTeX}\quad\Lcs{XeLaTeX}
+\end{BDef}
+\textsf{bidi} defines \XeTeX\ and \XeLaTeX\ logos and in addition, it makes sure that logos, \TeX, \LaTeX, \LaTeXe\ are typeset LTR.
+\subsection{Separation Mark}
+\begin{BDef}
+\Lcs{SepMark}\Largb{\Larga{mark}}\quad\Lcs{@SepMark}
+\end{BDef}
+Generally in Standard \LaTeX, dot is used for separation between section numbers, equation numbers any anything else which needs to be seperated. You can use \Lcs{SepMark} to use any other mark as the seperation mark instead a dot.
+\begin{lstlisting}[morekeywords={SepMark,subsection,subsubsection}]
+\documentclass{article}
+\usepackage{bidi}
+\SepMark{-}
+\begin{document}
+\section{First}
+\subsection{Second}
+\subsubsection{Third}
+\end{document}
+\end{lstlisting}
+
+If you decide to change the numbering of chapters, sections, subsections, equations, figures and \ldots, you should either load \textsf{amsmath} package and use \Lcs{numberwithin} macro to do this or do the ordinary way, but instead dot write \Lcs{@SepMark}. Using dot instead \Lcs{@SepMark} will certainly make trouble.
+
+\begin{lstlisting}[morekeywords={theequation,thesection,SepMark}]
+\documentclass{article}
+\usepackage{bidi}
+\SepMark{-}
+\makeatletter
+\renewcommand\theequation{\thesection\@SepMark\@arabic\c@equation}
+\makeatother
+\begin{document}
+\section{First}
+\begin{equation}
+x^2+y^2=z^2
+\end{equation}
+\end{document}
+\end{lstlisting}
+\subsection{\Lcs{raggedright}, \Lcs{raggedleft} commands, \texttt{flushleft} and \texttt{flushright} Environments}
+\Lcs{raggedright} command and \texttt{flushleft} environment put the text on the left hand side and \Lcs{raggedleft} command and \texttt{flushright} environment put the text on the right hand side, independent on the current mode.
+\subsection{Primitive-like commands}
+\begin{BDef}
+\Lcs{hboxR}\quad\Lcs{hboxL}\quad\Lcs{vboxR}\quad\Lcs{vboxL}
+\end{BDef}
+\begin{itemize}
+\item The syntax of \Lcs{hboxR} is exatly the same as the syntax of \Lcs{hbox}, but its contents is always typeset RTL.
+\item The syntax of \Lcs{hboxL} is exatly the same as the syntax of \Lcs{hbox}, but its contents is always typeset LTR.
+\item The syntax of \Lcs{vboxR} is exatly the same as the syntax of \Lcs{vbox}, but its contents is always typeset RTL.
+\item The syntax of \Lcs{vboxL} is exatly the same as the syntax of \Lcs{vbox}, but its contents is always typeset LTR.
+\end{itemize}
+\subsection{Something To know about \Lcs{hbox}}
+If you enable RTL typesetting and typeset an horizontal box at the beginning of the document:
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\setRTL
+\begin{document}
+\hbox{This is a Test}
+\end{document}
+\end{lstlisting}
+You see that even you have used \Lcs{setRTL}, the horizontal box appears LTR (It appears on the left hand side and its content is typeset left to right). This is because when \TeX{} starts, it is in the vertical mode so if you need to have that \Lcs{hbox} appear RTL, then write \Lcs{leavevmode} before \Lcs{hbox}:
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\setRTL
+\begin{document}
+\leavevmode\hbox{This is a Test}
+\end{document}
+\end{lstlisting}
+\subsection{\Lcs{bidillap} and \Lcs{bidirlap} Commands}
+In RTL mode, \Lcs{llap} and \Lcs{rlap} do oposite things. Since these two macros are used in a lot of classes and packages, instead modifying these two macros, we have created two new macros \Lcs{bidillap} and \Lcs{bidirlap} which give logical results.
+\subsection{\textsf{LTRitems} and \textsf{RTLitems} Environments}
+If you typeset an \textsf{itemize}, or an \textsf{enumerate}, or a \textsf{description} environment where all \Lcs{item}s are one directional, you have no problem at all as shown below:
+\begin{lstlisting}
+\documentclass{article}
+\begin{document}
+Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\begin{enumerate}
+\item Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\item Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\end{enumerate}
+\end{document}
+\end{lstlisting}
+However if the above example becomes bidirectional, as shown below:
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\begin{document}
+Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\begin{enumerate}
+\item Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\setRTL
+\item Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\end{enumerate}
+\end{document}
+\end{lstlisting}
+Then some people may argue that this typographically does not look promising. For this purpose, \textsf{RTLitems} environment is provided which has the following syntax:
+\begin{BDef}
+\LBEG{RTLitems}\\
+\quad\Lcs{item} \Larga{text}\\
+\quad\ldots\\
+\LEND{RTLitems}
+\end{BDef}
+ By using the \textsf{RTLitems} environment, the previous example will look like the following:
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\begin{document}
+Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\begin{enumerate}
+\item Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\begin{RTLitems}
+\item Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's
+\end{RTLitems}
+\end{enumerate}
+\end{document}
+\end{lstlisting}
+Similarly, \textsf{LTRitems} environment is defined which has the following syntax:
+\begin{BDef}
+\LBEG{LTRitems}\\
+\quad\Lcs{item} \Larga{text}\\
+\quad\ldots\\
+\LEND{LTRitems}
+\end{BDef}
+\subsection{\textsf{LTRbibitems} and \textsf{RTLbibitems} Environments}
+The syntax of \textsf{LTRbibitems} and \textsf{RTLbibitems} environments is exactly like the syntax of \textsf{LTRitems} and \textsf{RTLitems} environments but there are few differences:
+\begin{itemize}
+\item \textsf{LTRitems} and \textsf{RTLitems} environments should only be used for \textsf{list}-like environments (such as \textsf{itemize}, \textsf{enumerate} and \textsf{description} environments) but \textsf{LTRbibitems} and \textsf{RTLbibitems} environments should only be used for \textsf{thebibliography} environment.
+\item Clearly instead of \Lcs{item}, you have \Lcs{bibitem} inside \textsf{LTRbibitems} and \textsf{RTLbibitems} environments.
+\end{itemize}
+\subsection{\Lcs{setLTRbibitems}, \Lcs{setRTLbibitems}, and \Lcs{setdefaultbibitems} commands}
+\begin{BDef}
+\Lcs{setLTRbibitems}\quad\Lcs{setRTLbibitems}\quad\Lcs{setdefaultbibitems}
+\end{BDef}
+\begin{itemize}
+\item If your whole \textsf{thebibliography} environment is inside RTL mode, but all your \Lcs{bibitem}s are LTR and you actually want to have \Lcs{bibname} to appear on the RHS, you can use \Lcs{setLTRbibitems} command before \textsf{thebibliography} environment.
+\item If your whole \textsf{thebibliography} environment is inside LTR mode, but all your \Lcs{bibitem}s are RTL and you actually want to have \Lcs{bibname} to appear on the LHS, you can use \Lcs{setRTLbibitems} command before \textsf{thebibliography} environment.
+\item \Lcs{setdefaultbibitems} is the default, when your \Lcs{bibitems} are a mixture of LTR and RTL and it does not matter what mode (LTR or RTL) your \textsf{thebibliography} environment is in. Please note that you do not have to use \Lcs{setdefaultbibitems} command in this case at all.
+
+Consider an example that your \textsf{thebibliography} environment is inside LTR mode and you have, say two \Lcs{bibitem}s. The first \Lcs{bibitem} is LTR and the second \Lcs{bibitem} is RTL. One could typeset this senario as shown below:
+\begin{lstlisting}
+\documentclass{article}
+\usepackage{bidi}
+\begin{document}
+\begin{thebibliography}{99}
+\bibitem This is the first bibitem which is LTR.
+\begin{RTLbibitems}
+\bibitem This is the second bibitem which is RTL.
+\end{RTLbibitems}
+\end{thebibliography}
+\end{document}
+\end{lstlisting}
+\end{itemize}
+
+\subsection{Typesetting margin par}
+By default, in RTL mode, \Lcs{marginpar} appears on LHS and its content is typeset RTL and in LTR mode, \Lcs{marginpar} appears on RHS and its content is typeset LTR. In addition, the following commands are provided:
+\begin{BDef}
+\Lcs{setRTLmarginpar}\quad\Lcs{setLTRmarginpar}\quad\Lcs{setdefaultmarginpar}\\
+\Lcs{LTRmarginpar}\Largs{\Larga{left-text}}\Largb{\Larga{right-text}}\\
+\Lcs{RTLmarginpar}\Largs{\Larga{left-text}}\Largb{\Larga{right-text}}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{setRTLmarginpar} always makes \Lcs{marginpar} to appear on LHS and the content of \Lcs{marginpar} is typeset RTL (this is independent of the current mode).
+\item \Lcs{setLTRmarginpar} always makes \Lcs{marginpar} to appear on RHS and the content of \Lcs{marginpar} is typeset LTR (this is independent of the current mode).
+\item \Lcs{setdefaultmarginpar} gives the default behaviour of \Lcs{marginpar} as described above.
+\item \Lcs{LTRmarginpar} typesets \Larga{left-text} and \Larga{right-text} always LTR.
+\item \Lcs{RTLmarginpar} typesets \Larga{left-text} and \Larga{right-text} always RTL.
+\item in RTL mode, places of \Larga{left-text} and \Larga{right-text} swaps.
+\end{itemize}
+\subsection{Typesetting of Headers and Footers}
+If the main direction of the document is RTL, then headers and footers are typeset RTL and if the main direction of the document is LTR, then headers and footers are typeset LTR.
+\subsection{Tabular Typesetting}
+In RTL mode, tabular are typeset RTL and in LTR mode, tabular are typeset LTR.
+\subsection{Equation Numbers}
+For \texttt{reqno}, equation numbers are on the right hand side and for \texttt{leqno}, equation numbers are on the left hand side, independent on the current mode.
+\section{Support For Various Packages and Classes}
+The \textsf{bidi} package supports \textsf{amsmath}, \textsf{amstext}, \textsf{amsthm}, \textsf{array}, \textsf{arydshln}, \textsf{breqn}, \textsf{cals}, \textsf{caption}, \textsf{color}, \textsf{colortbl}, \textsf{crop}, \textsf{cuted}, \textsf{cutwin}, \textsf{dblfnote} \textsf{draftwatermark}, \textsf{empheq}, \textsf{fancyhdr}, \textsf{fancybox}, \textsf{fix2col}, \textsf{float}, \textsf{floatrow}, \textsf{flowfram}, \textsf{framed}, \textsf{ftnright}, \textsf{geometry}, \textsf{graphicx}, \textsf{hvfloat}, \textsf{hyperref}, \textsf{lettrine}, \textsf{listings}, \textsf{mdframed}, \textsf{midfloat}, \textsf{minitoc}, \textsf{multicol}, \textsf{multienum}, \textsf{newfloat}, \textsf{pdfpages}, \textsf{pstricks}, \textsf{quotchap}, \textsf{picinpar}, \textsf{ragged2e}, \textsf{rotating}, \textsf{sidecap}, \textsf{stabular}, \textsf{subfig}, \textsf{subfigure}, \textsf{supertabular}, \textsf{xtab}, \textsf{tabls}, \textsf{tabulary}, \textsf{PGF \&\ TIKZ}, \textsf{tocbibind}, \textsf{tocloft}, \textsf{tocstyle}, \textsf{wrapfig}, \textsf{xcolor}, \textsf{xltxtra} packages, \textsf{amsart}, \textsf{amsbook}, \textsf{artikel1}, \textsf{artikel2}, \textsf{artikel3}, \textsf{extarticle}, \textsf{flashcards}, \textsf{standrad article}, \textsf{boek}, \textsf{boek3}, \textsf{standard book}, \textsf{bookest}, \textsf{extbook}, \textsf{extletter}, \textsf{scrlettr},\textsf{standard letter}, \textsf{memoir}, \textsf{extreport}, \textsf{rapport1}, \textsf{rapport3}, \textsf{refrep}, \textsf{standard report}, \textsf{scrartcl}, \textsf{scrbook}, \textsf{scrreprt} classes and any other packages and classes that relies on these packages and classes. This means, you can use all these packages and classes in addition to other packages and classes that rely on these packages and classes and use their functionality fully for your bidirectional documents.
+
+We now give some details that you should know about the supported packages or classes.
+\subsection{Color}
+You can use \textsf{color} and \textsf{xcolor} packages to typeset texts in colours and colour boxes produced by \Lcs{colorbox} and \Lcs{fcolorbox} commands. Please note that your Coloured text should not span more than a line, if your text spans more than a line, you will be in trouble which means your whole document, page or paragraph may be coloured. If your texts spans more than a line, then you should use \textsf{xecolor} package.
+
+Also if you are going to use \Lcs{color} command to colour the text at the beginning of a paragraph, then you should have \Lcs{leavevmode} before \Lcs{color} command.
+
+For having coloured tabular, you can use \textsf{colortbl} package.
+\subsection{The \textsf{dblfnote} package}
+The \textsf{dblfnote} package makes footnotes double-columned. In addition \textsf{bidi} package adds bidirectional support for the \textsf{dblfnote} package by providing the following commands:
+\begin{BDef}
+\Lcs{RTLdfnmakecol}\qquad\Lcs{LTRdfnmakecol}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{RTLdfnmakecol} makes footnotes double-columned RTL.
+\item \Lcs{LTRdfnmakecol} makes footnotes double-columned LTR.
+\item If the main direction of the document is RTL, \Lcs{RTLdfnmakecol} is active and if the main direction of the document is LTR, \Lcs{LTRdfnmakecol} is active.
+\end{itemize}
+ Please note that when using \textsf{dblfnote} package, the footnote rule will be as wide as the footnote column and \Lcs{autofootnoterule}, \Lcs{rightfootnoterule}, \Lcs{leftfootnoterule}, and \Lcs{textwidthfootnoterule} commonds have no effects.
+\subsection{Hyperref}
+The \textsf{hyperref} package works fine with bidirectional documents if and only if, your link will not span more than a line. If your link spans more than a line, then your whole document, or page or paragraph may be linked.
+
+
+\subsection{\textsf{flowfram} Package}
+You can use \textsf{flowfram} package for your bidirectional documents. Please note that \textsf{flowfram} package provides support for bidirectional column typesetting, for details, see its manual.
+\subsection{Multicolumn Typesetting}
+In the previous versions of \textsf{bidi} package, it was recommended that you need to use \textsf{fmultico} package instead the original \textsf{multicol} package for RTL multicolumn typesetting. This is not the case any more and you should not use buggy \textsf{fmultico} package any more. Simply load the original \textsf{multicol} package before loading \textsf{bidi}. \textsf{bidi} now supports \textsf{multicol} package and you can typeset bidirectional multi columns.
+
+In addition, you also can use \textsf{vwcol} package for variable width bidirectional column typesetting.
+\section{Extra \textsf{bidi} Packages and Classes}
+\subsection{\textsf{bidi-longtable} package}
+ For typesetting RTL tables with \textsf{longtable} package, an experimental package, \textsf{bidi-longtable} package, is provided. \textsf{bidi-longtable} package should be loaded after \textsf{longtable} package.
+\subsection{\textsf{biditufte} bundle}
+A modified version of \textsf{tufte-latex}, \textsf{biditufte} bundle, mainly for RTL typesetting, is provided. If you never used \textsf{biditufte} bundle or \textsf{tufte-latex} package and you want to use \textsf{biditufte} bundle, then you need to look at \textsf{tufte-latex} package's manual and examples. In addition, for using \textsf{biditufte} bundle, you need to know the following notes:
+\begin{itemize}
+\item You need to use \textsf{biditufte-book} class instead \textsf{tufte-book} class and \textsf{biditufte-handout} class instead \textsf{tufte-handout} class.
+\item \textsf{biditufte} bundle provides the following extra commands:
+\begin{BDef}
+\Lcs{LTRsidenote}\quad\Lcs{RTLsidenote}\quad\Lcs{LTRmarginnote}\quad\Lcs{RTLmarginnote}
+\end{BDef}
+\item \textsf{biditufte-book} and \textsf{biditufte-handout} classes provide two extra options; \textsf{RTLgeometry} (active when loading either of classes) and \textsf{LTRgeometry}.
+\item \textsf{biditufte} bundle unlike \textsf{tufts-latex} package, only provides justified lines.
+\item Some features of \textsf{tufte-latex} that does not make any sense in RTL, do not exist in \textsf{biditufte} bundle (no need for \textsf{soul}, \textsf{letterspace} and \textsf{macrotype} packages).
+\item If you want to configure \textsf{biditufte-book} class for your own needs, then you can create a file with the name \texttt{biditufte-book.cfg} and put your \LaTeX{} macros in that file; similarly, if you want to configure \textsf{biditufte-handout} class for your own needs, then you can create a file with the name \texttt{biditufte-handout.cfg} and put your \LaTeX{} macros in that file.
+\end{itemize}
+\subsection{Typesetting \TeX{} and \LaTeX{} Codes}
+The \LaTeX{} codes in this manual are typeset using the \textsf{bidicode} package.
+In standard \LaTeX\, you can not use footnotes inside \Lcs{chapter}, \Lcs{part}, \Lcs{section}, \Lcs{subsection}, \Lcs{subsection} and any other section-like commands, \Lcs{caption} and tabular environment.
+
+\textsf{bidi} package provides \textsf{bidiftnxtra} package that solves the issue of footnote in standard \LaTeX. \textsf{bidiftnxtra} package should be loaded after \textsf{bidi} package.
+\subsection{Typesetting Poems}
+The \textsf{bidi} package provides \textsf{bidipoem} package for typesetting Persian poems. It provides four environments, \texttt{traditionalpoem}, \texttt{modernpoem} and starred version of these. In the starred version of these environments you do not need to type {\ttfamily\symbol{92}\symbol{92}} and that is the only difference with the normal version of the environments. The \texttt{traditionalpoem} environment and its starred version are also useful for typesetting Classic Arabic poetry, in fact this package may also be useful for other RTL languages.
+
+When using \textsf{bidipoem} package, at least you need to run \texttt{xelatex} twice on your document. In fact, if you run \texttt{xelatex} just once on your document, you get a message saying ``Unjustified poem. Rerun \texttt{XeLaTeX} to get poem right''.
+
+When you typeset your poems, you might get underfull \Lcs{hbox} messages. This is absolutely normal and if you want to get rid of these underfull \Lcs{hbox} messages, then you would need to use Kashida.
+
+If you need to change the default distance between two verses, you can do just that by:
+\begin{BDef}
+\Lcs{renewcommand}\Lcs{poemcolsepskip}\Largb{\Larga{length}}
+\end{BDef}
+\begin{BDef}
+\LBEG{traditionalpoem}\\
+\Larga{verse1}\texttt{\&}\Larga{verse2}{\ttfamily\symbol{92}\symbol{92}}\\
+\Larga{verse3}\texttt{\&}\Larga{verse4}{\ttfamily\symbol{92}\symbol{92}}\\
+\ldots\\
+\LEND{traditionalpoem}
+\end{BDef}
+\begin{BDef}
+\LBEG{traditionalpoem*}\\
+\Larga{verse1}\texttt{\&}\Larga{verse2}\\
+\Larga{verse3}\texttt{\&}\Larga{verse4}\\
+\ldots\\
+\LEND{traditionalpoem*}
+\end{BDef}
+\subsection{Typesetting Resum\'e}
+The \textsf{bidi} package provides \textsf{bidimoderncv}\footnote{This class is the modified version of \textsf{moderncv} class.} class for typesetting resum\'es. There are two examples, namely \texttt{test-casualcv.tex} and \texttt{test-classiccv.tex}, in the \textsf{doc} folder than you can look and learn how you can use it.
+\subsection{Print Two Pages On A Single Page}
+\textsf{bidi} package provides \textsf{bidi2in1} package for printing two pages on a single (landscape) A4 page. Page numbers appear on the included pages, and not on the landscape 'container' page.
+
+\subsection{Producing Presentations}
+At the moment, there is only one class that you can prepare your presentations
+with.
+
+\subsubsection{\textsf{bidipresentation} Class}
+\textsf{bidipresentation} is a simple class for presentations to be shown on
+screen or beamer. It is derived from \LaTeX's article class. The “virtual paper
+size” of documents produced by this class: width=128mm, height=96mm.
+\textsf{bidipresentation} requires that the \textsf{fancyhdr} and \textsf{geometry} packages
+are available on the system. Enhancements to the \textsf{bidipresentation}
+class are easily made available by other packages, these include slides with
+a background from a bitmap (\textsf{eso-pic} package).
+
+\paragraph{Usage:}
+The class is used with
+\begin{BDef}
+\Lcs{documentclass}\OptArgs\Largb{bidipresentation}
+\end{BDef}
+ Options of the article class are also available to \textsf{bidipresentation}, e. g.
+ 10pt, 11pt, 12pt for selection of font size. However, not all options of the
+ article class will be appropriate for a presentation class, e. g. twocolumn.
+
+A simple example document:
+\begin{lstlisting}[morekeywords={AddToShipoutPicture,includegraphics,distance}]
+ \documentclass[12pt]{bidipresentation}
+ \usepackage{eso-pic}
+ \usepackage[RTLdocument]{bidi}
+ \pagestyle{pres}
+ \AddToShipoutPicture{
+ \includegraphics{gradient2.png}
+}
+ \begin{document}
+ \begin{titlepage}
+\centering
+ \distance{1}
+ {
+\Huge \bfseries Title of the presentation \par
+}
+ \vspace{1.3ex} \large
+ Author\\[2ex]Institution
+ \distance{2}
+ \end{titlepage}
+ \begin{plainslide}[Title of Page]
+The first page
+\end{plainslide}
+\begin{rawslide}
+The second page
+ \end{rawslide}
+\end{document}
+\end{lstlisting}
+The title page can be created within the \texttt{titlepage} environment, the \Lcs{maketitle}
+command is not available. Slides may be created with the \texttt{plainslide} environment, you may add the title of the slide with the optional parameter. The
+contents of the slide are centered vertically. Another environment generating a slide is \texttt{rawslide}: slides are written without title, contents are not
+vertically centered.
+
+The \Lcs{distance}\Largb{\Larga{number}} command allows to introduce vertical space into
+slides constructed with the \texttt{rawslide} and \texttt{titlepage} environments. You should
+use pairs of \Lcs{distance}\Largb{} commands with numbers indicating the relative
+height of empty space, see the titlepage in the example above.
+
+Pictures can be included with the \Lcs{includegraphics} command of the \textsf{graphicx} package. Please be aware that the dimensions of the pages are 128mm $\times$
+96mm and therefore included graphics are scaled appropriately.
+
+\paragraph{Enhancements to \textsf{bidipresentation}:}
+
+\subparagraph{Fill background of a presentation with bitmaps:}
+\textsf{eso-pic} package allows you to paint the background with a picture:
+\begin{lstlisting}[morekeywords={AddToShipoutPicture,includegraphics}]
+\usepackage{eso-pic}
+...
+\AddToShipoutPicture{
+\includegraphics{gradient2.png}
+}
+\end{lstlisting}
+\Lcs{AddToShipoutPicture}\Largb{} puts the picture on every page, \Lcs{AddToShipoutPicture*}\Largb{}
+puts it on to the current page, \Lcs{ClearShipoutPicture} clears the background
+beginning with the current page. Details of \textsf{eso-pic}’s commands can be
+found in its own documentation.
+
+
+
+\section{Some Useful Internal Macros and Programming Tips}
+There are some useful internal macros and programming tips that might be helpful for you. This section, explains all these useful internals and programming tips.
+\subsection{Equating Conditionals}
+\begin{BDef}
+\Lcs{eqnewif}\Largb{\Larga{\Lcs{newconditional1}}}\Largb{\Larga{\Lcs{newconditional2}}}
+\end{BDef}
+In standard \LaTeX, \Lcs{newif} command is provided that you can define a new conditional with it. \Lcs{eqnewif} command is similar to \Lcs{newif} command but:
+\begin{itemize}
+\item With \Lcs{eqnewif} command, you can define two new conditionals instead one, so clearly it has two mandatory arguments.
+\item \Lcs{newconditional1} will be identical to \Lcs{newconditional2}, so that whenever \Lcs{newconditional1} is true, then \Lcs{newconditional2} is also true and whenever \Lcs{newconditional1} is false, then \Lcs{newconditional2} is also false and vice versa.
+\end{itemize}
+\subsection{RTL Conditional}
+\begin{BDef}
+\Lcs{if@RTL}
+\end{BDef}
+\Lcs{if@RTL} conditional is true inside RTL mode and it is false in LTR mode.
+\subsection{Main RTL Conditional}
+\begin{BDef}
+\Lcs{if@RTLmain}
+\end{BDef}
+If the main direction of the document is RTL, \Lcs{if@RTLmain} is true and if the main direction of the document is LTR, \Lcs{if@RTLmain} is false.
+\subsection{Latin Conditional}
+\begin{BDef}
+\Lcs{if@Latin}
+\end{BDef}
+\Lcs{if@Latin} inside any environment that uses Latin font is true and inside any environment that uses RTL font is false.
+\subsection{Tags Internal Macro}
+\begin{BDef}
+\Lcs{@iftagsloaded}\Largb{\Larga{tags name}}\Largb{\Larga{do thing(s) if the tag is loaded}}\\
+\Largb{\Larga{do thing(s) if the tag is not loaded}}
+\end{BDef}
+As you can see, the syntax of \Lcs{@iftagsloaded} is exactly the same as the syntax of \Lcs{@ifpackageloaded} and \Lcs{@ifclassloaded}. By tags, we mean things like \texttt{leqno} or \texttt{reqno}. Please note that in the argument \Larga{tags name}, the extension \texttt{clo} should not be given.
+\subsection{Definition File Loaded Internal Macro}
+\begin{BDef}
+\Lcs{@ifdefinitionfileloaded}\Largb{\Larga{definition file name}}\\
+\Largb{\Larga{do thing(s) if the definition file is loaded}}\\
+\Largb{\Larga{do thing(s) if the definition file is not loaded}}
+\end{BDef}
+As you can see, the syntax of \Lcs{@ifdefinitionfileloaded} is exactly the same as the syntax of \Lcs{@ifpackageloaded} and \Lcs{@ifclassloaded}. By definition file, we mean things like \texttt{hyperref-bidi.def} or \texttt{wrapfig-bidi.def}. Please note that in the argument \Larga{definition file name}, the extension \texttt{def} should not be given.
+\subsection{Tabular Conditional}
+\begin{BDef}
+\Lcs{if@RTLtab}
+\end{BDef}
+If the tabular is typeset RTL, \Lcs{if@RTLtab} is true and if the tabular is typeset LTR, \Lcs{if@RTLtab} is false.
+\subsection{Footnote Conditional}
+\begin{BDef}
+\Lcs{if@RTL@footnote}
+\end{BDef}
+When footnotes are typeset RTL, \Lcs{if@RTL@footnote} is true and when footnotes are typeset LTR, \Lcs{if@RTL@footnote} is false.
+\subsection{Direction Ensuring Macros}
+\begin{BDef}
+\Lcs{@ensure@RTL}\Largb{\Larga{text}}\quad\Lcs{@ensure@RL}\Largb{\Larga{text}}\quad\Lcs{@ensure@LTR}\Largb{\Larga{text}}\\
+\Lcs{@ensure@LR}\Largb{\Larga{text}}\quad
+\Lcs{@ensure@dir}\Largb{\Larga{text}}\quad\Lcs{@ensure@maindir}\Largb{\Larga{text}}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{@ensure@RTL} and \Lcs{@ensure@RL} internals make sure that \Larga{text} is always typeset RTL, independent on the current mode.
+\item \Lcs{@ensure@LTR} and \Lcs{@ensure@LR} internals make sure that \Larga{text} is always typeset LTR, independent on the current mode.
+\item \Lcs{@ensure@dir} and \Lcs{@ensure@maindir} if used in RTL mode, they put \Larga{text} inside \Lcs{RLE} and if used in LTR mode, they put the text as it is.
+\end{itemize}
+\subsection{Reset Direction Macro}
+\begin{BDef}
+\Lcs{save@dir}\quad\Lcs{saved@@dir}\quad\Lcs{reset@dir}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{save@dir}, if the direction of typesetting is RTL, defines \Lcs{saved@@dir} to be RTL and if the direction of typesetting is LTR, defines \Lcs{saved@@dir} to be LTR.
+\item \Lcs{reset@dir}, if \Lcs{saved@@dir} is defined as RTL, inserts \Lcs{setRTL} otherwise, if \Lcs{saved@@dir} is defined as LTR, inserts \Lcs{setLTR}, otherwise does nothing.
+\end{itemize}
+\part{Plain \TeX\ Manual}
+\section{Basics}
+\subsection{Loading The Package}
+You can load the package in the ordinary way;
+\begin{BDef}
+\Lcs{input} \Larg{bidi}
+\end{BDef}
+
+When loading the package, it is important to know that:
+\textsf{bidi} should be the last package that you load, because otherwise you are certainly going to overwrite \textsf{bidi}'s definitions and consequently, you will not get the expected output.
+\subsection{Commands for Version number, and Date of The Package}
+\begin{BDef}
+\Lcs{bidiversion}\quad\Lcs{bididate}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{bidiversion} gives the current version of the package.
+\item \Lcs{bididate} gives the current date of the package.
+\end{itemize}
+\begin{lstlisting}
+\input bidi
+This is typeset by \textsf{bidi} package, \bidiversion, \bididate.
+\end
+\end{lstlisting}
+\subsection{Turning TeX-{-}XeT features on and off}
+The bidirectional typesetting in \XeTeX{} is based on TeX-{-}XeT algorithm and \textsf{bidi} package automatically turns the feature on for typesetting bidirectional texts. As the internal data structures built by TeX-{-}XeT differ from those built by \TeX, the typesetting of a document by TeX-{-}XeT may therefore differ from that performed by \TeX. So you may notice that some packages behave differently when TeX-{-}XeT feature is on and you may want to turn the feature off for a part of the text so that you get the default behaviour of original \TeX. Two commands are provided for this purpose:
+\begin{BDef}
+\Lcs{TeXXeTOn}\quad\Lcs{TeXXeTOff}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{TeXXeTOn} turns TeX-{-}XeT feature on, which is active by default when \textsf{bidi} package is loaded.
+\item \Lcs{TeXXeTOff} turns TeX-{-}XeT feature off.
+\end{itemize}
+\subsection{Paragraph Switching Commands\label{PSC}}
+\begin{BDef}
+\Lcs{setLTR}\quad\Lcs{setLR}\quad\Lcs{unsetRL}\quad\Lcs{unsetRTL}\\
+\Lcs{setRTL}\quad\Lcs{setRL}\quad\Lcs{unsetLTR}
+\end{BDef}
+\begin{itemize}
+\item With any of the commands in the first row, you can typeset LTR paragraphs.
+\item With any of the commands in the second row, you can typeset RTL paragraphs.
+\end{itemize}
+\begin{lstlisting}[morekeywords={newfontfamily,Parsifont}]
+\input bidi
+\setRTL%
+Anyone who reads Old and Middle English literary texts will be
+ familiar with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+
+\setLTR% Notice the blank line before \setLTR
+Anyone who reads Old and Middle English literary texts will be
+ familiar with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\end
+\end{lstlisting}
+\subsection{Pargraph Switching Environments}
+\begin{BDef}
+\Lcs{LTR}\quad\Larga{text}\quad\Lcs{endLTR}\\
+\Lcs{RTL}\quad\Larga{text}\quad\Lcs{endRTL}
+\end{BDef}
+\begin{itemize}
+\item With \texttt{LTR} environment, you can typeset LTR paragraphs.
+\item With \texttt{RTL} environment, you can typeset RTL paragraphs.
+\end{itemize}
+\begin{lstlisting}[morekeywords={RTL,endRTL,LTR,endLTR}]
+\input bidi
+\RTL
+Anyone who reads Old and Middle English literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\LTR
+Anyone who reads Old and Middle English literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\endLTR
+And we are still typesetting right to left.
+\endRTL
+\end
+\end{lstlisting}
+\subsection{Typesetting Short LTR and RTL Texts}
+\begin{BDef}
+\Lcs{LRE}\Largb{\Larga{text}}\quad\Lcs{LR}\Largb{\Larga{text}}\\
+\Lcs{RLE}\Largb{\Larga{text}}\quad\Lcs{RL}\Largb{\Larga{text}}
+\end{BDef}
+\begin{itemize}
+\item With any of the commands in the first row, you can typeset short LTR text inside RTL paragraphs.
+\item With any of the commands in the second row, you can typeset short RTL text inside LTR paragraphs.
+\end{itemize}
+\begin{lstlisting}[morekeywords={RTL,endRTL,LTR,endLTR}]
+\input bidi
+\RTL
+Anyone who reads Old and Middle English \LRE{Short left to right text} literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\LTR
+Anyone who reads Old and Middle English \RLE{Short right to left text} literary texts will be familiar
+ with the mid-brown volumes of the EETS, with the symbol
+ of Alfred's jewel embossed on the front cover.
+\endLTR
+\endRTL
+\end
+\end{lstlisting}
+\subsection{Primitive-like commands}
+\begin{BDef}
+\Lcs{hboxR}\quad\Lcs{hboxL}\quad\Lcs{vboxR}\quad\Lcs{vboxL}
+\end{BDef}
+\begin{itemize}
+\item The syntax of \Lcs{hboxR} is exatly the same as the syntax of \Lcs{hbox}, but its contents is always typeset RTL.
+\item The syntax of \Lcs{hboxL} is exatly the same as the syntax of \Lcs{hbox}, but its contents is always typeset LTR.
+\item The syntax of \Lcs{vboxR} is exatly the same as the syntax of \Lcs{vbox}, but its contents is always typeset RTL.
+\item The syntax of \Lcs{vboxL} is exatly the same as the syntax of \Lcs{vbox}, but its contents is always typeset LTR.
+\end{itemize}
+\subsection{Something To know about \Lcs{hbox}}
+If you enable RTL typesetting and typeset an horizontal box at the beginning of the document:
+\begin{lstlisting}
+\input bidi
+\setRTL
+\hbox{This is a Test}
+\end
+\end{lstlisting}
+You see that even you have used \Lcs{setRTL}, the horizontal box appears LTR (It appears on the left hand side and its content is typeset left to right). This is because when \TeX{} starts, it is in the vertical mode so if you need to have that \Lcs{hbox} appear RTL, then write \Lcs{leavevmode} before \Lcs{hbox}:
+\begin{lstlisting}
+\input bidi
+\setRTL
+\leavevmode\hbox{This is a Test}
+\end
+\end{lstlisting}
+\subsection{Typesetting Logos}
+\begin{BDef}
+\Lcs{XeTeX}
+\end{BDef}
+\textsf{bidi} defines \XeTeX\ logo and in addition, it makes sure that the logo, \TeX\ is typeset LTR.
+\section{Some Useful Internal Macros and Programming Tips}
+There are some useful internal macros and programming tips that might be helpful for you. This section, explains all these useful internals and programming tips.
+\subsection{RTL Conditional}
+\begin{BDef}
+\Lcs{if@RTL}
+\end{BDef}
+\Lcs{if@RTL} conditional is true inside RTL mode and it is false in LTR mode.
+\subsection{Main RTL Conditional}
+\begin{BDef}
+\Lcs{if@RTLmain}
+\end{BDef}
+If the main direction of the document is RTL, \Lcs{if@RTLmain} is true and if the main direction of the document is LTR, \Lcs{if@RTLmain} is false.
+\subsection{Direction Ensuring Macros}
+\begin{BDef}
+\Lcs{@ensure@RTL}\Largb{\Larga{text}}\quad\Lcs{@ensure@RL}\Largb{\Larga{text}}\quad\Lcs{@ensure@LTR}\Largb{\Larga{text}}\\
+\Lcs{@ensure@LR}\Largb{\Larga{text}}\quad
+\Lcs{@ensure@dir}\Largb{\Larga{text}}\quad\Lcs{@ensure@maindir}\Largb{\Larga{text}}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{@ensure@RTL} and \Lcs{@ensure@RL} internals make sure that \Larga{text} is always typeset RTL, independent on the current mode.
+\item \Lcs{@ensure@LTR} and \Lcs{@ensure@LR} internals make sure that \Larga{text} is always typeset LTR, independent on the current mode.
+\item \Lcs{@ensure@dir} and \Lcs{@ensure@maindir} if used in RTL mode, they put \Larga{text} inside \Lcs{RLE} and if used in LTR mode, they put the text as it is.
+\end{itemize}
+\subsection{Reset Direction Macro}
+\begin{BDef}
+\Lcs{save@dir}\quad\Lcs{saved@@dir}\quad\Lcs{reset@dir}
+\end{BDef}
+\begin{itemize}
+\item \Lcs{save@dir}, if the direction of typesetting is RTL, defines \Lcs{saved@@dir} to be RTL and if the direction of typesetting is LTR, defines \Lcs{saved@@dir} to be LTR.
+\item \Lcs{reset@dir}, if \Lcs{saved@@dir} is defined as RTL, inserts \Lcs{setRTL} otherwise, if \Lcs{saved@@dir} is defined as LTR, inserts \Lcs{setLTR}, otherwise does nothing.
+\end{itemize}
+\end{document} \ No newline at end of file