(Follow-up to Making LaTeX documents with Hebrew? (in Sweave + RStudio))

Trying to reproduce the above answer, I followed these instructions without success, under Windows 7.

The best result I got so far is a document containing correct Hebrew text, but backwards (meaning RTL) R output. It means that the whole document is right-aligned, even the English parts.

BTW, I was using the knitr function, as sweave was not functioning at all. My Encoding is UTF-8.

I would appreciate any tips or solution!


%  This document must be compiled with Sweave and xelatex (not pdflatex)
\usepackage[noae]{Sweave} % you must load Sweave with the `noae` option
% load polyglossia late in the package load order, since the bidi package (which is
% loaded when an RTL language is set) redefines lots of package code.
\setmainfont{David CLM}
% for R work with Hebrew, it's important to have a mono font that supports
% the Hebrew script.  Miriam Mono is one that I know of
\setmonofont[Script=Hebrew]{Miriam Mono CLM}  
\title{\textenglish{Side-by-side xtables}}
ראשית קצת קוד R כדי ליצור כמה נתונים.
myData <- matrix(c(19,89,23,23,74,44,16,39,67),ncol=3,byrow=TRUE)
colnames(myData) <- c("A","B","C")
rownames(myData) <- c("1","2","3")
myData2 <- myData * 2

כעת אנו שמים את הנתונים בשני צדדי על ידי צד טבלאות:

\captionof{table}{\textenglish{First Table}}
  add.to.row=list(pos=list(-1,0, nrow(myData)),

\captionof{table}{\textenglish{Second Table}}
  add.to.row=list(pos=list(-1,0, nrow(myData2)),


(sorry, the system doesn't allow me to upload pics... but believe me, the whole page is right-aligned, and the R code is reversed)


Since I cannot compile Hebrew documents (I may need to install certain fonts), here is my guess which might work. Put this in your LaTeX preamble and see if it works:


The LTR environment was suggested by Alan Munn, and I have no idea of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.