This #recipe shows how to export a note to PDF.
- Pandoc
- A LaTeX distribution such as TeXLive (Linux), MacTeX (MacOS), or MikTeX (Windows)
Check that Pandoc is installed by opening a terminal and running pandoc --version
.
Check that Pandoc can produce PDFs with LaTeX by running the following in the terminal.
echo It is working > test.md
pandoc test.md -o test.pdf
-
Create a folder in your workspace named
.pandoc
. Take note of the full path to this directory. The rest of this recipe will refer to this path as$WORKSPACE/.pandoc
. -
Download the template file
foam.latex
from Hegghammer/foam-templates and place it in$WORKSPACE/.pandoc
. -
In VSCode, open
settings.json
for your user (or just for your workspace if you prefer), and add the following line:
"pandoc.pdfOptString": "--from=markdown+wikilinks_title_after_pipe --resource-path $WORKSPACE/.pandoc --template foam --listings",
Make sure to replace $WORKSPACE/.pandoc
with the real full path to the .pandoc
directory you created earlier.
-
Open a Foam note in VSCode.
-
Press
Ctrl
+k
,p
. Choose "pdf", and pressEnter
.
The PDF should look something like this:
If you include a name in the author
parameter in the YAML of the Foam note, that name will feature in the PDF header on the top left.
If you don't want syntax highlighting and frames around the codeblocks, remove --listings
from the pandoc.pdfOptString
parameter in settings.json
.
If you know some LaTeX, you can tweak the foam.latex
template to your needs. Alternatively, you can supply another ready-made template such as Eisvogel; just place the TEMPLATE_NAME.latex
file in $WORKSPACE/.pandoc
. You can also use all of Pandoc's other functionalities by tweaking the pandoc.pdfOptString
parameter in settings.json
.