6

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
14
  • 2
    As it says you have to use a mono font that contains these chars. And no, I do not know any.
    – daleif
    Commented Oct 23, 2020 at 13:40
  • @daleif Thanks for response. The font Noto Color Emoji is installed by default on my Ubuntu 20.04. I tried setting mainfont: Noto Color Emoji but failed. I wonder what can be done. I have two ideas : 1. try lualatex with some special pakcages 2. try last resort. Commented Oct 23, 2020 at 16:13
  • noto color emoji can be used, but imho only with lualatex. Commented Oct 23, 2020 at 16:43
  • @UlrikeFischer Thx for response. I tried replacing xelatex with lualatex for --pdf-engine, but I ran into the problem of "missing loca table". lualatex-dev has to be used, which is not supported by pandoc. Commented Oct 23, 2020 at 23:21
  • In texlive 2020 lualatex-dev is not needed anymore. Commented Oct 24, 2020 at 7:14

1 Answer 1

5

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

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .