简体   繁体   English

pandoc markdown 到 pdf:修复缺失字符警告?

[英]pandoc markdown to pdf: fixing missing character warnings?

I have seen How do I fix "missing character" warnings when converting from docx to pdf using Pandoc and LaTeX?我已经看到使用 Pandoc 和 LaTeX 从 docx 转换为 pdf 时如何修复“缺失字符”警告? - but unfortunately, the advice there does not seem to apply to this test case: - 但不幸的是,那里的建议似乎不适用于这个测试用例:

$ 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]:!

So, there are some specific "box drawing" glyphs, missing from Latin Modern Mono - so probably they are used in a context of code snippets.因此,拉丁现代 Mono 中缺少一些特定的“方框绘图”字形 - 因此它们可能在代码片段的上下文中使用。

Is there a way to provide a "fallback font" in this case?在这种情况下有没有办法提供“后备字体”? Or how could I solve this otherwise, so I can produce a (Latex) PDF from these markdown files via pandoc?或者我怎么能以其他方式解决这个问题,所以我可以通过 pandoc 从这些 markdown 文件中生成一个 (Latex) PDF?


EDIT: found:编辑:发现:

... so I tried: ...所以我试过:

header-includes.yaml : 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
...

... and then I tried (note, using just single file from the repo, raspi-config.md , here): ... 然后我尝试了(注意,这里只使用来自 repo 的单个文件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

... so, cannot get this approach to work, either... ...所以,也无法使这种方法起作用...

You can see what's happening by checking how pandoc parsed the input, eg by converting it back to Markdown: pandoc -t native -s -t markdown -V header-includes='' header-includes.yaml您可以通过检查 pandoc 如何解析输入来查看发生了什么,例如将其转换回 Markdown: pandoc -t native -s -t markdown -V header-includes='' header-includes.yaml

---
header-includes: |
  ```{=tex}
  \usepackage{combofont}
  \setupcombofont{multiscript-regular}
  ```
  { {file:lmsans10-regular.otf:`\combodefaultfeat`{=tex}} at \#1pt,
  {file:DejaVuSans.ttf} at \#1pt, {file:NotoSansCJK-Regular.ttc(0)} at
  \#1pt } { {} , fallback, fallback }
  `\DeclareFontFamily{TU}{multiscript}{}`{=tex}
  `\DeclareFontShape {TU}{multiscript}{m}{n}`{=tex}
  {\<-\>combo\*multiscript-regular}{}
  `\fontfamily{multiscript}`{=tex}`\selectfont`{=tex}
---

You'll note that some parts are not recognized as TeX but as plain text.您会注意到某些部分未被识别为 TeX,而是被识别为纯文本。 Force interpretation as a LaTeX block by using raw attribute syntax :使用原始属性语法强制解释为 LaTeX 块:

---
header-includes: |
  - ```{=latex}
    \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
    ```
...

Or you could write the TeX snippets into a file and pass that via the -H option, which will insert the file contents unchanged into the intermediary LaTeX file.或者您可以将 TeX 片段写入文件并通过-H选项传递,这会将文件内容原封不动地插入到中间文件 LaTeX 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM