TransWikia.com

pandoc codeblock containing Unicode characters

TeX - LaTeX Asked by GNUSupporter 8964民主女神 地下教會 on April 18, 2021

Motivation

In Julia, many Unicode characters are allowed as identifier. This facilitates the reading of algorithms containing greek letters like α, λ, ετc.

enter image description here

Question

How to fix the following Markdown codeblock so that pandoc can compile it to PDF?

```julia
? = 2
```

Minimal example test.md.

Error received

$ pandoc --pdf-engine=xelatex test.md -o test.pdf
[WARNING] Missing character: There is no ? in font [lmmono10-regular]:!

I tried

---
mainfont: Liberation Serif
---

```julia
? = 2
```

but I’m getting the same error.


(Edited)

My TeX Live 2020 :

enter image description here

I’ve tried mixing normal text with emojis and compile with LuaLaTeX, but only emojis were shown when the main font is set to Noto Emoji Color.

enter image description here


(Edit) Thanks to comment, I’ve managed to get LuaLaTeX working with

documentclass{minimal}
usepackage{fontspec}
directlua
{luaotfload.add_fallback
 ("myfallback",
  {
   "NotoColorEmoji:mode=harf;"
  }
 )
}
setmainfont{LatinModernRoman}[
 RawFeature={fallback=myfallback}
]
begin{document}
It ? lorem ? LaTeX.
end{document}

My new try:

---
header-includes: |
  directlua
  {luaotfload.add_fallback
   ("myfallback",
    {
     "NotoColorEmoji:mode=harf;"
    }
   )
  }
mainfont: LatinModernRoman
mainfontoptions:
- RawFeature={fallback=myfallback}
---

It ? lorem ? LaTeX.

Error received:

$ pandoc --pdf-engine=lualatex test.md -o test.pdf
Error producing PDF.
! Undefined control sequence.
<argument> LaTeX3 error: 
                Misplaced equals sign in key-value input on line 17
l.17 fi

One Answer

You are getting the errors because pandoc treats the header as Markdown. You need to tell it to treat your header as a LaTeX code block.

However even after doing this, it still fails because the template puts the font selection before it inserts the header material. So you need to put the font selection in your header for things to happen in the right order.

You can use:

pandoc -s test.md -o test.tex

to see the intermediate tex file and diagnose what is going wrong.

Putting it all together, this will work:

---
header-includes:
- |
  ```{=latex}
  directlua{luaotfload.add_fallback(
               "myfallback",
               {"NotoColorEmoji:mode=harf;"}
             )}
  setmainfont[RawFeature={fallback=myfallback}]{LatinModernRoman}
  setmonofont[RawFeature={fallback=myfallback}]{LatinModernMono}
  ```
---

It ? lorem ? LaTeX.

```julia
? = 2
```

And then run:

pandoc --pdf-engine=lualatex test.md -o test.pdf

which gives:

output

Correct answer by David Purton on April 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP