%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: rlbicig.sty
% Date: October 1st, 2001
% Author: Oliver Corff
% (c) 2001 Ulaanbaatar, Macau, Berlin
%
% No options.
%
% NB: This package requires eLaTeX2e!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Identification
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rlbicig}
[2001/10/01 v0.8 Horizontal/Vertical Support for mls]
%
%
% Preliminary declarations
%
% Well, I think, I'll shamelessly copy code from
% the Hebrew package and redefine a few things:
%
% \eL
% \R
%
% \RtoLtrue means that the main mode is currently Mongolian, Manju RL.
% \RtoLfalse means that the main mode is currently Latin, Cyrillic LR.
%\newif\ifRtoL
% Change the main mode to Hebrew RL or English LR (default mode).
% This is the only place the \ifRtoL value changes. Inner mode changes
% with \eL{} \R{} \rmbox{} and \lmbox{} does not change it.
%
\def\setRtoL{\RtoLtrue\beginR}
\def\setLtoR{\RtoLfalse\beginL}
% Macros for changing direction, taken from TUGboat.
% Usage: \eL{English Text} and \R{Mongol Bicig}.
% Numbers should also be enclosed in \eL{}, as in \eL{123}.
\let\next=\
\def\eL{\protect\pL}
\def\pL{\protect\afterassignment\moreL \let\next= }
\def\moreL{\bracetext \aftergroup\endL \beginL}
\def\R{\protect\pR}
\def\pR{\protect\afterassignment\moreR \let\next= }
\def\moreR{\bracetext \aftergroup\endR \beginR}
\def\bracetext{\ifcat\next{\else\ifcat\next}\fi
\errmessage{Missing left brace has been substituted}\fi \bgroup}
\everydisplay{\ifRtoL\aftergroup\beginR\fi }
%\everybox{\ifRtoL\aftergroup\beginR\fi }
% Take care of Hebrew indentation in every paragraph.
%
% Changes:
% \noindent for Hebrew. Yaniv.
% What about Mongol Bicig?
%
\def\bicigpar{\ifRtoL\kern-\parindent\beginR\indent\fi}
\let\oldeverypar\everypar
\def\everypar#1{\oldeverypar{\bicigpar#1}}
\let\oldnoindent\noindent
\def\noindent{\ifRtoL\indent\unskip\else\oldnoindent\fi}
% Additions by Yaniv:
% Useful vbox commands. All text in math formulas is best enclosed in these.
% ex: $P=\{x|\lmbox{The is no } y \lmbox{ such that } y \lmbox{ divides }x\}$
% $P=\{x|x\rmbox{ Mehalek et } y\rmbox{ Kach She } y\rmbox{ Lo Kayam }\}$
% \mbox{} is useless for both cases, since it typesets in LR Hebrew.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% List environments %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% List environments in Hebrew, are ticked and indented from the right
% instead of from the left. All the definitions that caused indentation
% are revised for Hebrew. LaTeX keeps track on the indentation with the
% \leftmargin and \rightmargin values. The changes below are mostly to
% exchange these values in Hebrew mode.
%
\def\descriptionlabel#1{\hspace\labelsep \textbf{#1}}
\def\description{\list{}{\labelwidth\z@ \itemindent-
\ifRtoL\rightmargin\else\leftmargin\fi
\let\makelabel\descriptionlabel}}
\let\enddescription\endlist