Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beamer presentation with Pandoc and Markdown - Persian characters don't show properly

I have a simple markdown like this:

---
dir: rtl
title: "درس روش پژوهش و ارائه"
author: "امیر شبانی"
date: "یک‌شنبه - ۱ دی ۱۳۹۸"
---

I save it in a file named Presentation.md and compile using this command:

pandoc Presentation.md -t beamer -o Presentation.pdf --pdf-engine=xelatex -V mainfont="Sahel"

The command runs without any error, but the font is not showing properly:

enter image description here

If I change the font from Sahel to BNazanin, it works fine:

enter image description here

But I'm interested in Sahel font. Is there any way I can fix it?

I don't think the font is corrupt, because it's showing fine in other programs, such as

VSCode:

enter image description here

Telegram:

enter image description here

Firefox:

enter image description here

like image 834
Amir Shabani Avatar asked Dec 21 '19 08:12

Amir Shabani


1 Answers

As suggested by @tarleb, I asked my question on TeX.StackExchange and got an answer. The person that answered the question doesn't have an Stack Overflow account, so I'm just gonna copy their answer here, in case someone finds this question first.

All that was needed was to specify the -V lang=ar in the original command, so that Pandoc doesn't load the default English script of the font. The font is Persian, but apparently since Arabic and Persian have similar letters, setting the language to Arabic works. So I can achieve what I wanted in two ways:

Specify the language in the command, when compiling:

Using this command,

pandoc pres.md -t beamer -o pres.pdf --pdf-engine=xelatex -V mainfont="Sahel" -V lang=ar

we can see that it works:

enter image description here

Specifying the language in the markdown file's metadata (Which I personally prefer)

So my markdown file would look like this:

---
lang: ar
dir: rtl
title: "درس روش پژوهش و ارائه"
author: "امیر شبانی"
date: "یک‌شنبه - ۸ دی ۱۳۹۸"
---

And we can see that this method works as well:

enter image description here

like image 95
Amir Shabani Avatar answered Jan 02 '23 08:01

Amir Shabani