使用 Pandoc 和 Markdown 的 Beamer 演示 - 波斯字符无法正确显示
Beamer presentation with Pandoc and Markdown - Persian characters don't show properly
我有一个像这样的简单降价:
---
dir: rtl
title: "درس روش پژوهش و ارائه"
author: "امیر شبانی"
date: "یکشنبه - ۱ دی ۱۳۹۸"
---
我将它保存在名为 Presentation.md
的文件中并使用此命令进行编译:
pandoc Presentation.md -t beamer -o Presentation.pdf --pdf-engine=xelatex -V mainfont="Sahel"
命令运行没有任何错误,但字体显示不正确:
如果我将字体从 Sahel
更改为 BNazanin
,它可以正常工作:
但我对 Sahel
字体很感兴趣。有什么办法可以解决吗?
我不认为字体损坏,因为它在其他程序中显示正常,例如
VSCode:
电报:
火狐:
这里, 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建议,以防有人先发现这个问题。
只需要在原始命令中指定 -V lang=ar
,这样 Pandoc
就不会加载字体的默认英文脚本。字体是波斯语,但显然由于阿拉伯语和波斯语有相似的字母,将语言设置为阿拉伯语作品。所以我可以通过两种方式实现我想要的:
在命令中指定语言,编译时:
使用这个命令,
pandoc pres.md -t beamer -o pres.pdf --pdf-engine=xelatex -V mainfont="Sahel" -V lang=ar
我们可以看到它有效:
在 markdown 文件的元数据中指定语言(我个人更喜欢)
所以我的降价文件看起来像这样:
---
lang: ar
dir: rtl
title: "درس روش پژوهش و ارائه"
author: "امیر شبانی"
date: "یکشنبه - ۸ دی ۱۳۹۸"
---
而且我们可以看到这个方法同样有效:
我有一个像这样的简单降价:
---
dir: rtl
title: "درس روش پژوهش و ارائه"
author: "امیر شبانی"
date: "یکشنبه - ۱ دی ۱۳۹۸"
---
我将它保存在名为 Presentation.md
的文件中并使用此命令进行编译:
pandoc Presentation.md -t beamer -o Presentation.pdf --pdf-engine=xelatex -V mainfont="Sahel"
命令运行没有任何错误,但字体显示不正确:
如果我将字体从 Sahel
更改为 BNazanin
,它可以正常工作:
但我对 Sahel
字体很感兴趣。有什么办法可以解决吗?
我不认为字体损坏,因为它在其他程序中显示正常,例如
VSCode:
电报:
火狐:
这里
只需要在原始命令中指定 -V lang=ar
,这样 Pandoc
就不会加载字体的默认英文脚本。字体是波斯语,但显然由于阿拉伯语和波斯语有相似的字母,将语言设置为阿拉伯语作品。所以我可以通过两种方式实现我想要的:
在命令中指定语言,编译时:
使用这个命令,
pandoc pres.md -t beamer -o pres.pdf --pdf-engine=xelatex -V mainfont="Sahel" -V lang=ar
我们可以看到它有效:
在 markdown 文件的元数据中指定语言(我个人更喜欢)
所以我的降价文件看起来像这样:
---
lang: ar
dir: rtl
title: "درس روش پژوهش و ارائه"
author: "امیر شبانی"
date: "یکشنبه - ۸ دی ۱۳۹۸"
---
而且我们可以看到这个方法同样有效: