1

On MacOS 12.6.9, I try to convert a Markdown file to PDF. For this, I'm using pandoc 3.1.2, installed with Homebrew. There are problems converting the characters and , which I use for expressing logical formulas. For instance, with this file utf.md

X ∧ Y ∨ Z

which in hex (xxd utf.md) would be

5820 e288 a720 5920 e288 a820 5a0a 0a

and LANG being set to en_GB.UTF-8, the command pandoc -s -o utf.pdf utf.md produces the error message

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

Googling for the problem, I found the suggestion to use xelatex as LaTeX engine. So I tried

pandoc -s --pdf-engine=xelatex -o utf.pdf utf.md

This resulted in

[WARNING] Missing character: There is no ∧ (U+2227) (U+2227) in font [lmroman10-regular]:mapping=t
[WARNING] Missing character: There is no ∨ (U+2228) (U+2228) in font [lmroman10-regular]:mapping=t

and, not surprisingly, the generated pdf file did not include those two characters. I conclude that the font (lmroman10-regular) does not include glyphs for these characters.

No my question is: What font would be suitable here, and how do I specify that font for pandoc?

UPDATE

About the font reported by Pandoc (lmroman10): I looked at the fonts installed on my Mac (using the the application Font Book), and there is no font named lmroman, so I'm puzzled where pandoc gets this font from.

1 Answer 1

1

You should try to upgrade your brew packages with brew upgrade - this will be useful for a newer version of pandoc, since, starting with May 2022 in Markdown you can insert inline expressions with $ $ or block expressions with $$ $$. Instead of the utf symbols used by you, try the LaTeX symbols \lor and \land for logical expressions, so your math expression should be $ X \land Y \lor Z $.

As for fonts, I assume you have LaTeX installed, so the Latin modern fonts are in e.g. /usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm.

The above expression rendered in .pdf:

enter image description here

You should check out the pandoc version (mine is 3.1.7 on Ventura). Please note I did not choose/set any LaTeX font - what you see is the pandoc work. This is achieved with katex or mathjax at export stage. Also, the export to html is easy, with this command: --from=markdown --to=html5 --standalone --katex --template=elegant_bootstrap_menu.html (choose a html template of your own) The result:

enter image description here

6
  • Use xelatex engine, as you discovered. In my example I changed the order of logical operations, this should not be problem.
    – Yoan
    Commented Sep 16, 2023 at 11:44
  • I have installed pandoc this year in june, so it should be pretty new. I would rather not like putting latex code directly into my Markdown document, because the same base document is supposed to be used for generating HTML as well. Isn't there a suitable font, which I can use with xelatex, which already contains these characters? Commented Sep 16, 2023 at 12:39
  • I had meanwhile time to turn to this problem again. Actually, output to HTML is not a problem; I have solved the HTML part. My problem is PDF. I have upgraded pandoc to 3.1.8 now. The directory /usr/local/texlive/2022/texmf-dist/fonts/opentype/public/lm does not exist on my Mac. I see a directory /usr/local/texlive/2023basic/texmf-var. Not knowing any LaTeX, I would be grateful if you could let me know what else I need to generate my PDF. Current command is pandoc -s --pdf-engine=xelatex. Commented Sep 26, 2023 at 13:25
  • I have full 2022 texlive distribution, you seem to have the 2023 version, so the differences in paths. My command to get .pdf is pandoc --pdf-engine=xelatex -V documentclass=scrarticle -V geometry:a4paper -V geometry:margin=2cm -V geometry:nohead --listings my-file.md -o my-file.pdf and all is OK. I think the problem may be the mode you typed unicode - in my case I use Unicode Hex Input keyboard, works also with your original codes U+2227/2228.
    – Yoan
    Commented Oct 4, 2023 at 7:48
  • My input file is UTF-8 encoded, so the characters are presented there just as this encoding specifies. BTW, what is the documentclass used for? Do I need this too? Commented Nov 3, 2023 at 8:09

You must log in to answer this question.

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