I was trying to quickly convert a CommonMark markdown document to PDF but got into errors (elaborating on these below), but are there any simple instructions somewhere on how to set up Pandoc that just works for the most basic purposes out of the box? (This is kind of subjective, I know.)
Lucked out with trial and error for now, but this method is not ideal (and may not always work). Out of all the manuals (Nix, Nixpkgs, NixOS), only the NixOS one mentions pandoc
at all, so it’s not there. The only other thread here that closely related was this but it wasn’t helpful in my case.
$ nix-shell -p pandoc
$ pandoc input.md -o out.pdf
pdflatex not found. Please select a different --pdf-engine or install pdflatex
Not sure how to find which Nix packages offer an arbitrary executable (in this case, pdflatex
), so tried this:
$ pdflatex
The program ‘pdflatex’ is currently not installed. It is provided by
several packages. You can install it by typing one of the following:
nix-env -iA nixos.texlive.combined.scheme-basic
nix-env -iA nixos.texlive.combined.scheme-minimal
nix-env -iA nixos.texlive.combined.scheme-small
So I went through each of these in order:
$ nix-shell -p texlive.combined.scheme-basic
$ pandoc input.md -o out.pdf
Error producing PDF.
! LaTeX Error: File `xcolor.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.36 \IfFileExists
$ exit
No luck.
$ nix-shell -p texlive.combined.scheme-minimal
$ pandoc input.md -o out.pdf
kpathsea: Running mktexfmt pdflatex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt: /nix/store/61nxl1s0fkfgjj9s01f1b6kk7f5vvrcg-texlive-combined-minimal-2019/share/texmf/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt: /home/toraritte/.texlive2019/texmf-config/web2c/fmtutil.cnf
mktexfmt [INFO]: writing formats under /home/toraritte/.texlive2019/texmf-var/web2c
mktexfmt [INFO]: --- remaking pdflatex with pdftex
mktexfmt [WARNING]: inifile pdflatex.ini for pdflatex/pdftex not found.
mktexfmt [INFO]: disabled formats: 5
mktexfmt [INFO]: not selected formats: 53
mktexfmt [INFO]: failed to build: 1 (pdftex/pdflatex)
mktexfmt [INFO]: total formats: 59
mktexfmt [INFO]: exiting with status 1
kpathsea: Running mktexfmt pdflatex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt: /nix/store/61nxl1s0fkfgjj9s01f1b6kk7f5vvrcg-texlive-combined-minimal-2019/share/texmf/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt: /home/toraritte/.texlive2019/texmf-config/web2c/fmtutil.cnf
mktexfmt [INFO]: writing formats under /home/toraritte/.texlive2019/texmf-var/web2c
mktexfmt [INFO]: --- remaking pdflatex with pdftex
mktexfmt [WARNING]: inifile pdflatex.ini for pdflatex/pdftex not found.
mktexfmt [INFO]: disabled formats: 5
mktexfmt [INFO]: not selected formats: 53
mktexfmt [INFO]: failed to build: 1 (pdftex/pdflatex)
mktexfmt [INFO]: total formats: 59
mktexfmt [INFO]: exiting with status 1
Error producing PDF.
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/NixOS.org) (preloaded format=pdflatex)
restricted \write18 enabled.
I can't find the format file `pdflatex.fmt'!
$ exit
No luck.
$ nix-shell -p texlive.combined.scheme-small
$ pandoc input.md -o out.pdf
Bingo. For the record, it seems as these packages also have pdflatex
, so I could’ve gone on, but it would have been very time-consuming (e.g., had to quit installing texlive.combined.scheme-full
after 30 minutes as I had to leave…)
$ nix-shell -p texlive.combined.scheme- # TAB TAB
texlive.combined.scheme-basic texlive.combined.scheme-gust texlive.combined.scheme-minimal
texlive.combined.scheme-context texlive.combined.scheme-infraonly texlive.combined.scheme-small
texlive.combined.scheme-full texlive.combined.scheme-medium texlive.combined.scheme-tetex