Skip to content

Instantly share code, notes, and snippets.

@keuv-grvl
Last active June 28, 2024 05:26
Show Gist options
  • Save keuv-grvl/12f386624061672637997790fc2d0472 to your computer and use it in GitHub Desktop.
Save keuv-grvl/12f386624061672637997790fc2d0472 to your computer and use it in GitHub Desktop.
Convert Markdown to PDF within Sublime Text using Pandoc
{
"cmd": ["pandoc --latex-engine=xelatex --filter=pandoc-citeproc -o '$file_base_name.pdf' '$file_name'"],
"selector": "text.html.markdown",
"shell": true
}
@SpectralHiss
Copy link

I think also that the --filter=pandoc-citeproc bit is no longer required in my version of pandoc (2.15) it worked without it.
However, I needed to add lmodern latex sty package by simply doing sudo apt-get install lmodern

Thanks for the gist!

@yanisallouch
Copy link

I'm using pandoc version 1.19.2.4 , the updated snippet of @keuv-grvl should modify the argument name from --pdf-engine to --latex-engine.

As of today, the usage of latex-engine is no longer possible for pandoc v2.19.2 (windows tested) see my console output :

PS > pandoc --latex-engine=xelatex -o 'README.pdf' 'README.md'
--latex-engine has been removed.  Use --pdf-engine instead.
Try pandoc.exe --help for more information.
PS > pandoc -v
pandoc.exe 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.2.1
Scripting engine: Lua 5.4
User data directory: C:\Users\%USER%\AppData\Roaming\pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.7
PSEdition                      Core
GitCommitId                    7.2.7
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@promicrobial
Copy link

I'm using pandoc v2.9.2.1 on Linux Mint (21.3) and by changing --latex-engine=xelatex to --pdf-engine=pdflatex things were back in working order:

{
	"cmd": ["pandoc --pdf-engine=pdflatex --filter=pandoc-citeproc -o '$file_base_name.pdf' '$file_name'"],
	"selector": "text.html.markdown",
	"shell": true
}

There are several pdf engines you can use, including xelatex as used above: https://pandoc.org/MANUAL.html#option--pdf-engine

@gkunwar
Copy link

gkunwar commented Jun 28, 2024

This is the error in my MacOS.

pandoc: : withBinaryFile: does not exist (No such file or directory)

Screenshot 2024-06-28 at 11 09 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment