4

I have created a minimal reproducible example. I start with:

test.md

∀x ∈ ℕ ( P(x) )

and I am running the following command:

pandoc test.md -o test.pdf

I get the following error:

Error producing PDF. ! LaTeX Error: Unicode character ∀ (U+2200) not set up for use with LaTeX.

How can I solve this issue ?

F. Zer
  • 197

2 Answers2

3

For the comment:

Even though I can't change source code to enclose everything between $...$

Switching to xelatex or lualatex and using capable font as DeJaVu the example can be rendered "as is" without using the math mode (but of course, as plain text with the main font, so it will look very different):

enter image description here

---
format: pdf
pdf-engine: xelatex
mainfont: DejaVu Serif
---

∀x ∈ ℕ (P(x))

$∀x ∈ ℕ (P(x))$

Fran
  • 80,769
  • Upvoted, this works perfectly. Thank you. From the comments, and answers on this page, I think the ideal solution for me would be running a filter that expands unicode into its latex equivalent, in order to see the math font of your second example. – F. Zer May 16 '23 at 13:12
  • @F.Zer The math font of my second example is what you see here, that xelatex read "as is". If you add keep-tex: true to the header you can see that ∀x ∈ ℕ (P(x)) is not expanded to some like \forall x\in\mathbb{N}(P(x))in the LaTeX export. The only change is that TeX syntax $...$ is traduced to the more orthodox LaTeX syntax \(... \). If you need the pdflatex version (with commands) one way could be open LyX → Ctrl+N → Ctrl+M → paste ∀x ∈ ℕ (P(x)) → open the Code Preview Pane. I am not sure if this will work with any math symbol, but works for this example. – Fran May 16 '23 at 16:31
  • Not sure I understand. Before that, the code fence you used is markdown content to be processed by pandoc ? – F. Zer May 16 '23 at 17:48
  • The example is a Quarto markdown document (use the extension .qmd, not .md) that you can copile directly as pdf (and latex too, using the above YAML directive) with Rstudio, VScode or using directly quarto render foo.qmd, but you can also convert to a latex document with pandoc -s -f markdown -t latex foo.qmd -o foo.tex or to -t pdf if you add add also --pdf-engine=xelatex to pandoc command (otherwise it will try to use pdflatex, that do not understand ∀ ). – Fran May 16 '23 at 21:41
  • Thank you ! With that command, I get: > Error producing PDF. ! Package fontspec Error: The font "DejaVu Serif" cannot be found. – F. Zer May 17 '23 at 17:21
  • Could you tell me how to solve the issue ? – F. Zer May 17 '23 at 17:22
  • 1
    You can install the dejavu package with the package manager of your TeX distribution, or use any TTF or OTF even if its not part of the TeX distribution, as far it is correctly installed for your operative system (try "Symbola" for instance). In any case, you need to know the exact name of the font (that could be not the same of the font filename) and then check if it can print all the glyphs that you will need (be prepared for the negative results with many many fonts). – Fran May 17 '23 at 18:52
2

You need to write your formula in math mode $...$ (as already pointed out in the comments) and you have to use a pdf engine that understands unicode.

test.md

$∀x ∈ ℕ ( P(x) )$

and

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

enter image description here

DG'
  • 21,727