I got the same problem, using the default Pandoc installer for Windows (in C:\Program Files), and having a texlive installation in drive D: ... Then I usually call pandoc from a MSYS2 shell, which has both the above paths in its PATH, and I usually convert succesfully from, say, markdown to pdf.
So, these were the kind of commands that I tried, and were failing:
$ pandoc -s -t rst --toc rest_syntax.rst -o rest_syntax.pdf
cannot produce pdf output from rst
Then, this page knitr pandoc: "cannot produce pdf output with pdf writer" noted that:
... [*for pdf output, use latex or beamer and -o FILENAME.pdf] ...
So basically format = "pdf"
is invalid, you should use pandoc("tmp.Rmd", format = "latex", ext = "pdf")
...
Ok, then I remembered I actually use --pdf-engine
argument in most of my calls, when I convert markdown to pdf, so I tried:
$ pandoc -s -t rst --toc rest_syntax.rst --pdf-engine=pdflatex -o rest_syntax.pdf
pdf-engine pdflatex is not compatible with output format rst
$ pandoc -s -t rst --toc rest_syntax.rst --pdf-engine=xelatex -o rest_syntax.pdf
pdf-engine xelatex is not compatible with output format rst
$ pandoc -s -t rst --toc rest_syntax.rst --pdf-engine=lualatex -o rest_syntax.pdf
pdf-engine lualatex is not compatible with output format rst
... which I found quite bizarre ... But then I noticed "output format rst" - and, well, I do NOT want rst as output format! So I looked at pandoc --help
- and it turns out, -t
is --to
, that is, it specifies output format indeed!
So, once I removed that, finally this worked:
$ pandoc -s --toc rest_syntax.rst --pdf-engine=lualatex -o rest_syntax.pdf
[WARNING] Reference not found for 'Key "today"' at chunk line 1 column 8
[WARNING] Reference not found for 'python' at line 726 column 118
[WARNING] Reference not found for '#name' at line 811 column 30
[WARNING] Reference not found for '1' at line 822 column 53
[WARNING] Reference not found for '#' at line 823 column 32
And finally, this seems to work; note that the rest_syntax.rst
file is actually this: https://thomas-cokelaer.info/tutorials/sphinx/_sources/rest_syntax.txt - and not everything is formatted nicely in the PDF, but there is a toc, basic formatting and equations seem to work.