我看过如何使用Pandoc和LaTeX将docx转换为pdf时修复“缺失字符”警告?,但不幸的是,那里的建议似乎不适用于这个测试案例:
$ git clone https://github.com/raspberrypi/documentation.git
$ cd documentation/configuration
$ pandoc *.md --pdf-engine=xelatex -o result.pdf
[WARNING] Missing character: There is no ┌ (U+250C) in font [lmmono10-regular]:!
[WARNING] Missing character: There is no ─ (U+2500) in font [lmmono10-regular]:!
[WARNING] Missing character: There is no ─ (U+2500) in font [lmmono10-regular]:!
[WARNING] Missing character: There is no ─ (U+2500) in font [lmmono10-regular]:!
[WARNING] Missing character: There is no ─ (U+2500) in font [lmmono10-regular]:!
...
[WARNING] Missing character: There is no ─ (U+2500) in font [lmmono10-regular]:!
[WARNING] Missing character: There is no ─ (U+2500) in font [lmmono10-regular]:!
[WARNING] Missing character: There is no ┘ (U+2518) in font [lmmono10-regular]:!
所以,有一些特定的“方框绘制”字形,在Latin Modern Mono中缺失-因此它们可能在代码片段的上下文中使用。
在这种情况下,是否有一种提供“后备字体”的方法?或者我如何解决这个问题,以便通过pandoc从这些markdown文件生成(Latex)PDF?
编辑:找到:
- https://tex.stackexchange.com/questions/512396/inserting-any-unicode-character-in-latex-document
- https://tex.stackexchange.com/questions/139139/adding-headers-and-footers-using-pandoc
header-includes.yaml
:---
header-includes: |
\usepackage{combofont}
\setupcombofont{multiscript-regular}
{
{file:lmsans10-regular.otf:\combodefaultfeat} at #1pt,
{file:DejaVuSans.ttf} at #1pt,
{file:NotoSansCJK-Regular.ttc(0)} at #1pt
}
{
{} ,
fallback,
fallback
}
\DeclareFontFamily{TU}{multiscript}{}
\DeclareFontShape {TU}{multiscript}{m}{n} {<->combo*multiscript-regular}{}
\fontfamily{multiscript}\selectfont
...
然后我尝试了一下(注意,这里只使用了存储库中的单个文件raspi-config.md
):
$ pandoc header-includes.yaml ./raspi-config.md --pdf-engine=lualatex -o result.pdf
Error producing PDF.
! Paragraph ended before \setupcombofont was complete.
<to be read again>
\par
l.61
...所以,无法使这种方法奏效...
texlive
中了,但是我找不到它...所以我尝试着自己编译它,但它是用Kotlin编写的,需要使用gradlew
进行构建,而我并不是一个Java专家,所以也无法做到。否则,我将使用https://jdhao.github.io/2018/04/08/matplotlib-unicode-character/中列出的Python方法。 - sdbbs