<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{ltxdoc}
\input{bidi-doc-preamble.ltx}
\begin{document}
\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}</pre></body></html>