Markdown to PDF using Pandoc
Convert to PDF filePermalink
When I use pandoc to convert markdown to pdf on Windows. The command below fails and give me an error message.
pandoc file.md -o output.pdf
Typing the command below and then convert again will work.
updmap
Picture in wrong positionPermalink
The pictures in output all goes to the end of the file. The command below fixes it.
pandoc file.md -o output.pdf -f markdown-implicit_figures
Ugly code blocksPermalink
Using Eisvogel can output beautiful code blocks by the command below after installing the template.
pandoc file.md -o output.pdf --template eisvogel --listings
ChinesePermalink
fc-list :lang=zh
Find the available font, then execute the code below with the font you want.
pandoc file.md -o output.pdf --latex-engine=xelatex -V mainfont="Microsoft JhengHei"
::Or
pandoc file.md -o output.pdf --pdf-engine=xelatex -V CJKmainfont="Microsoft JhengHei"
Chinese auto-wrap (instead of slicing)Permalink
pandoc file.md -o output.pdf --pdf-engine=xelatex -V CJKmainfont="Microsoft JhengHei" --wrap=preserve
Full commandPermalink
pandoc file.md -o output.pdf --template eisvogel -f markdown-implicit_figures --listings --pdf-engine=xelatex -V CJKmainfont="Microsoft JhengHei" --wrap=preserve
Download pandoc template Eisvogel.
Further researchPermalink
Someday I’ll have a test on code highlighting. Pandoc: What are the available syntax highlighters?.
Further ReadingPermalink
- pdfTeX error (font expansion): auto expansion is only possible with scalable fonts | GitHub
- Error: pdfTeX error (font expansion): auto expansion is only possible with scalable fonts | GitHub
- Pandoc Markdown to PDF image position | Stack Overflow
- Pandoc with Chinese | GitHub
- Pandoc and foreign characters | Stack Overflow
Comments are configured with provider: disqus, but are disabled in non-production environments.