summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/bidi/bidi-doc-plain-basics.ltx
blob: 6b2d41946997b93733fd8a0e93a75cba05d29ffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
\documentclass{ltxdoc}
\input{bidi-doc-preamble.ltx}
\begin{document}
\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}
\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}
\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}
\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.
\end{document}