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

1

8

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

Pennington answered 21/12, 2019 at 8:3 Comment(1)
This is probably more of a LaTeX issue. Maybe the fine folks over at tex.stackexchange.com can help you.Babs
P
7

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

Pennington answered 30/12, 2019 at 16:1 Comment(1)
What text editor did you choose to write down Persian markdown ?Pistachio

© 2022 - 2024 — McMap. All rights reserved.