From af8dc2014749c0915211fb61af9ee56f1de65019 Mon Sep 17 00:00:00 2001 From: Drew Haven Date: Thu, 18 Jun 2026 10:47:03 -0700 Subject: [PATCH] Adds note on printing markdown files. --- src/content/notes/NixOS/Printing Markdown.md | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/content/notes/NixOS/Printing Markdown.md diff --git a/src/content/notes/NixOS/Printing Markdown.md b/src/content/notes/NixOS/Printing Markdown.md new file mode 100644 index 0000000..70bbd3c --- /dev/null +++ b/src/content/notes/NixOS/Printing Markdown.md @@ -0,0 +1,42 @@ +--- +title: Printing Markdown Files +--- + +Recently I had the need to print the content of one of my Markdown files. I had some notes that I wanted to take with me in physical form. However, the notes were mostly in bullet-point form, so it was terrible for printing. There would be tons of dead space. My goal is to print it in two columns so that the many short lines wouldn't leave a lot of dead space. I also wanted relatively small text size so that I wouldn't have a lot of pages to flip through when looking for something. + +The tool I'm familiar with to handle this is `pandoc`. It's a great tool for converting between different document formats. That includes LaTeX and PDF generation. + +The basic format of the pandoc command is as follows. In this case I have a half-inch margin, two columns, 8-point font and am using the FreeSerif font. I'm using the Tectonic PDF engine. + +```bash +pandoc input.md \ + -o Downloads/Rules.pdf \ + --pdf-engine=tectonic \ + -V classoption=twocolumn \ + -V fontsize=8pt \ + -V geometry:margin=0.5in \ + -V mainfont="FreeSerif" +``` + +### Fonts + +Getting the right font can be tricky. Listing the font names that are available can be accomplished with a quick command. What we are looking for is just the font family name. + +```bash +fc-list : family | sort -u | less +``` + +### Running it in Nix + +The whole command can be run in Nix without having to install anything by using `nix shell`. I use the new nix-commands instead of the old `nix-shell`. `pandoc` does not come with a PDF backend, I must include `tectonic` as well. + +```bash +nix shell 'nixpkgs#pandoc' 'nixpkgs#tectonic' -c \ + pandoc input.md \ + -o Downloads/Rules.pdf \ + --pdf-engine=tectonic \ + -V classoption=twocolumn \ + -V fontsize=8pt \ + -V geometry:margin=0.5in \ + -V mainfont="FreeSerif" +```