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 ?

3
  • 2
    Similar questions have been pointed to this question: Entering Unicode characters in LaTeX May 14, 2023 at 22:46
  • 1
    I'm not sure questions about pandoc is on-topic here. That having said I believe even in Markdown you need to delimit your math formulas with $...$.
    – user202729
    May 14, 2023 at 23:55
  • Thank you both of you. I am exploring unicode handling options.
    – F. Zer
    May 15, 2023 at 12:13

2 Answers 2

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

5
  • 1
    There are several solutions on Entering Unicode characters in LaTeX - TeX - LaTeX Stack Exchange that also allow using Unicode math characters in PDFLaTeX.
    – user202729
    May 15, 2023 at 9:11
  • @user202729 -- Sure, but it's unnecessarily complicated to set up (with pandoc). Why bother when switching the engine does the trick?
    – DG'
    May 15, 2023 at 9:42
  • 1
    Even though I can't change source code to enclose everything between $...$, it's a very neat trick, so I upvoted. Thank you @DG' !
    – F. Zer
    May 15, 2023 at 12:13
  • How is your source generated?
    – DG'
    May 15, 2023 at 14:35
  • Thanks for getting back, @DG'. The source is a markdown file with math written in unicode. I can't change it because it's better for readability purposes.
    – F. Zer
    May 16, 2023 at 12:59
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))$  
7
  • 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, 2023 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, 2023 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, 2023 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, 2023 at 21:41
  • 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, 2023 at 18:52

You must log in to answer this question.

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