带有Pandoc和Markdown的Beamer演示文稿-波斯字符无法正确显示

时间:2019-12-21 08:03:55

标签: markdown pandoc beamer

我有一个像这样的简单减价:

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

我将其保存在名为Presentation.md的文件中,并使用以下命令进行编译:

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

命令运行没有任何错误,但是字体显示不正确:

enter image description here

如果我将字体从Sahel更改为BNazanin,则效果很好:

enter image description here

但是我对Sahel字体感兴趣。有什么办法可以解决?

我不认为字体已损坏,因为它在其他程序(例如,

)中显示正常

VSCode:

enter image description here

电报:

enter image description here

Firefox:

enter image description here

1 个答案:

答案 0 :(得分:3)

根据@tarleb的建议,我在TeX.StackExchange上提出了问题,并得到了答案。回答问题的人没有堆栈溢出帐户,因此,如果有人首先找到此问题,我将在这里复制their answer

所需要做的就是在原始命令中指定-V lang=ar,以便Pandoc不会加载字体的默认英语脚本。字体是波斯语,但是显然是因为阿拉伯语和波斯语具有相似的字母,所以将语言设置为阿拉伯语作品。因此,我可以通过两种方式实现自己想要的目标:

在编译时在命令中指定语言:

使用此命令,

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

我们可以看到它有效:

enter image description here

在降价文件的元数据中指定语言(我个人更喜欢)

所以我的markdown文件看起来像这样:

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

我们可以看到此方法也能正常工作:

enter image description here