I am writing documents with both English and Hebrew text in LaTeX. It works well, except for one thing: when there is a punctuation mark after an English word in a Hebrew sentence, the mark is misplaced.
Here is a small reproducible example, a file named test.tex
:
\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\newfontfamily\hebrewfont{David CLM}
\let\hebrewfonttt\ttfamily
\begin{document}
המסמך הזה כתוב עם LaTeX, ומשלב בין עברית לאנגלית.
\par\noindent\rule{\textwidth}{0.4pt}
\setLTR
This document is written with LaTeX, and combines Hebrew and English.
\unsetLTR
\end{document}
which I process with:
xelatex test.tex
and get the following result:
In the first (Hebrew) sentence, the comma is misplaced. In the Hebrew sentence, the comma should be to the left of the word LaTeX, because the Hebrew text is RTL.
The correct arrangement can be seen in a text editor, such as gedit:
I'm not experienced with LaTeX, and couldn't find a solution online. Will appreciate any help with this, thank you very much!
LaTeX\/,
should work.tex
file example above, but doesn't work in RMarkdown (where I eventually need to prepare the text)