简体   繁体   中英

Special Characters in Markdown - Pandoc and Github Flavored

I'm trying to use "greater than or equal to" and "less than or equal to" symbols in a document that I'm producing in Markdown. I'm striving to have this document render correctly to a PDF via Pandoc and on GitHub, via Github flavored Markdown. However, I can't find a solution to produce these symbols that works in both interpretations of Markdown

The regular symbols (≥ and ≤) show-up fine in Git Flavored Markdown, as do HTML-style special characters. However, when I try to run that to get a PDF via Pandoc, I get this error:

pandoc test.md -o test.pdf
pandoc.exe: Error producing PDF from TeX source.
! Package inputenc Error: Unicode char \u8:≤ not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.120 ≤

Try running pandoc with --latex-engine=xelatex.

I've used the xelatex engine, and it simply doesn't produce a character in that place.

Latex-style special characters (eg, $\\geq$) render fine to a PDF via Pandoc but are not interpreted by Git Flavored Markdown.

Are there any suggestions for using special characters that work with Github flavored Markdown and Pandoc/Latex? Or is there a way to indicate to Pandoc/LaTeX that it needs to interpret HTML-formatted special characters or something?

The default LaTeX engine (pdflatex) doesn't play well with unicode. So using XeLaTeX is a good idea, but as @MatthewPickering mentioned, the font also needs to have a glyph for ≤, so switching the font to one that does solves the issue:

$ echo "≤" | pandoc --latex-engine=xelatex -o test.pdf --variable mainfont=Georgia

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM