简体   繁体   中英

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? - 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.

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?


EDIT: found:

... so I tried:

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):

$ 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

---
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. Force interpretation as a LaTeX block by using raw attribute syntax :

---
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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