Last active
December 26, 2015 16:12
-
-
Save Bersam/23eeaea5637a67f3f09b to your computer and use it in GitHub Desktop.
Sample Tex File With Full Bidi Support (Including Numbers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{xepersian} | |
\makeatletter | |
% classes 1-3 are used in unicode-letters.tex, so we'll put the Latin letters in 4 | |
\newcount\xp@n | |
\xp@n=`\A \loop \XeTeXcharclass \xp@n=4 \ifnum\xp@n<`\Z \advance\xp@n by 1 \repeat | |
\xp@n=`\a \loop \XeTeXcharclass \xp@n=4 \ifnum\xp@n<`\z \advance\xp@n by 1 \repeat | |
% this line would put Latin numbers in 4 class too. | |
\xp@n=`\0 \loop \XeTeXcharclass \xp@n=4 \ifnum\xp@n<`\9 \advance\xp@n by 1 \repeat | |
% when we encounter class 4, we'll do \startlatin | |
\XeTeXinterchartoks 0 4 {\startlatin} | |
\XeTeXinterchartoks 255 4 {\startlatin} | |
% and when we encounter class 0, we'll do \finishlatin | |
\XeTeXinterchartoks 255 0 {\finishlatin} | |
\XeTeXinterchartoks 4 0 {\finishlatin} | |
\newcommand{\startlatin}{\if@Latin\else\bgroup\beginL\latinfont\@Latintrue\fi} | |
\newcommand{\finishlatin}{\if@Latin\unskip\endL\egroup{ }\fi} | |
\makeatother | |
\XeTeXinterchartokenstate=1 | |
\begin{document} | |
این یک آزمایش است | |
One Two Three | |
و ادامه آن | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original snippet are from this stackexchange answer:
http://tex.stackexchange.com/a/54325