4

I'm using Pandoc to convert my markdown files to different formats including html and docx. With PDF though, I get the message pdflatex not found even though it was installed and I can even call it directly from Cygwin.

Why is Pandoc not detecting Pdflatex and what can I do to fix this issue?

1
  • How did you install pandoc?
    – evilsoup
    Commented Oct 26, 2014 at 12:39

2 Answers 2

4

I just ran into this - I suspect you installed the windows version of Pandoc. In cygwin, if you run which pandoc do you get something like /cygdrive/c/Program Files (x86)/Pandoc/pandoc?

If so, it appears that version expects windows-style paths (e.g. C:\path\to\pdflatex), but cygwin is probably giving it something like "/path/to/pdflatex".

You might find success building pandoc from source, inside your cygwin environment.

1
  • 1
    I was just looking at this and I think I see what is throwing pandoc. On Cygwin, pdflatex is a symlink to pdftex.exe. If you specify the full path using the --latex-engine switch, it errors out that "pandoc.exe: latex-engine must be pdflatex, lualatex, or xelatex."
    – Michael
    Commented Mar 15, 2016 at 18:34
1

@Wiscocrew's answer is on the right path, but, unfortunately, it is a little more complicated than that.

Pandoc permits you to pass the full path to pdflatex with the --latex-engine switch (c.f. http://pandoc.org/README.html#options-affecting-specific-writers), but if you just do something like

--latex-engine=`cygpath -w /usr/bin/pdflatex`

Pandoc gives a different error: pandoc.exe: latex-engine must be pdflatex, lualatex, or xelatex.. The reason for this error is that Cygwin's pdflatex is an symlink:

$ ls -lh /usr/bin/pdflatex
lrwxrwxrwx 1 myuser Domain Users 10 Mar 14 11:52 /usr/bin/pdflatex -> pdftex.exe

My work around was to copy /usr/bin/pdftex.exe to /usr/local/bin/pdflatex.exe and pass it to Pandoc like so:

pandoc Foo.md -o Foo.pdf --latex-engine='C:\\cygwin64\\usr\\local\\bin\\pdflatex.exe' -t latex -s
3
  • I guess to make this work seamlessly we would need pandoc compiled for cygwin in the first place. Commented Jan 19, 2017 at 5:15
  • 1
    I would think so, but each time I've tried to build GHC on Cygwin, I decided that life was just too short for that exercise.
    – Michael
    Commented Jan 19, 2017 at 6:12
  • Thank you so much. Finally PDF from Markdown under Cygwin! You saved the day. Commented Oct 22, 2018 at 18:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .