Consider the below MWE of .Rmd
file containing Arabic text which needs xelatex engine to be rendered by pandoc
. As the documentation of the latter says putting this option would make it: --latex-engine=xelatex
.
MWE
---
title: "Minimal Working Example `.Rmd` in Arabic"
author: "Author Name"
date: "Friday, July 08, 2016"
output: pdf_document
latex-engine: xelatex
---
----------
# مقدمة عن التقرير
# نتائج البحث
# الخلاصة
# Introduction of the Report
# Results
# Summary
So this how it appears in Emacs editor:
This is my setup:
- Ubuntu 16.04
- Emacs GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-04-17 on lgw01-04, modified by Debian
- Pandoc 1.16.0.2
polymode-mode
andmarkdown-mode
from MELPA latest as of this dateinit.el
setup in relation to polymode-mode- ESS 16.04
init.el - polymode-mode
(require 'poly-R)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))
(add-to-list 'auto-mode-alist '("\\.org" . poly-org-mode))
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd`enter code here`" . poly-markdown+r-mode))
init.el - customizataions
...
'(ess-rutils-keys t)
'(ess-swv-pdflatex-commands (quote ("xelatex" "pdflatex" "texi2pdf" "make")))
'(ess-swv-processor (quote knitr))
...
Primary Issue
When I export the .Rmd
buffer to pdf by M-n-e, I am prompted for 3 options: Rmarkdown-ESS
, Rmarkdown
, and pandoc
. I picked Rmarkdown-ESS
this was the error log:
/usr/bin/pandoc +RTS -K512m -RTS 4G_report.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /home/username/.emacs.d/docs/rstat/4th_examCom_program_2015_2016/4G_report[exported].pdf --template /home/username/R/my_R_library/rmarkdown/rmd/latex/default-1.15.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in'
! Package inputenc Error: Unicode char س (U+633)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.293 \end{verbatim}
Try running pandoc with --latex-engine=xelatex.
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
R>
so as you can see the error suggests using --latex-engine=xelatex
in pandoc instead of the default pdflatex. So how to set xelatex engine as default in polymode export? I tried to set the engine to xelatex in the YAML header but it didn't work. Or is there a way to change the value of a variable like pm-exporter/pandoc
?
Secondary Issue
When I export to html
I want the Arabic text direction to be from right-to-left and the English part of the text to be from left-to-right. Although I enjoy this bidi-direction inside Emacs editor, well this is one of the good reasons to pick this editor, but unfortunately I dont' get the same effect in the html export, and I don't know whether the same issue will arise int the pdf. So what do I need to get that effect in the exported document?