# xelatex: bidi problems with RTL character placing

I'm preparing a text on how bidirectional formatting works and using xelatex for that. For this I need to put RTL characters exactly as they are placed in the text, with disabled bidi processing, and my results are so far frustrating. Here's an example with hebrew (which by the way is also shown incorrectly here as code, but if you copy-paste it to a non-bidi editor the characters should follow the order as intended to, as 123אפס):

\documentclass{report}
\usepackage{fontspec}
\setmonofont{Courier New}
\setmainfont{Times New Roman}

\begin{document}
'123ספא'
\begin{verbatim}
'123ספא'
\end{verbatim}
\end{document}


Results so far are frustrating:

Is it possible either to disable bidi processing completely, at least or do something so that verbatim and non-verbatim results are the same?

Thank you

You can get the output you want like this (^^^^202d is the left-to-right-override U+202D):

\documentclass{report}
\usepackage{fontspec}

\setmonofont{Courier New}
\setmainfont{Times New Roman}

\begin{document}
'123ספא'

\ttfamily
^^^^202d'123^^^^202dספא'

\end{document}


But I have no idea why the apostroph needs the override too, and if there is a simpler method.

Have you tried \mbox{}? If it's just small portions of text you need in Hebrew, you could just enclose it in its own box. This takes care of the RTL issue.


\documentclass{report}
\usepackage{fontspec}
\setmonofont{Courier New}
\setmainfont{Times New Roman}

\begin{document}

123 \mbox{ספא}'

\end{document}

`