6

I currently have a project with a workflow that uses pandoc in its Makefile to convert text from Markdown to LaTeX to PDF. This requires that a LaTeX engine be present in my path, or specified with the --latex-engine option. The rest of my development is done in cygwin64 on 64-bit Windows 7.

Somehow, I'd had this mostly working previously with an installation of MiKTeX, but I was becoming annoyed with receiving two User Account Control (UAC) prompts per compilation, presumably as MiKTeX checked for missing packages. After doing a full reinstall of MiKTeX 2.9 using the "64-bit Net Installer" and including all packages, now when I run the following Makefile (pared down from the original):

PANDOC= pandoc
PDFLATEX=  /usr/bin/pdflatex
pdf:    main.tex
    $(PANDOC) main.tex -o main.pdf --latex-engine="$(PDFLATEX)"

... I receive the following error:

pandoc.exe: /usr/bin/pdflatex not found. /usr/bin/pdflatex is needed for pdf output.
Makefile:4: recipe for target 'pdf' failed
make: *** [pdf] Error 41

I've confirmed that /usr/bin/pdflatex does indeed exist, as a symlink to pdftex.exe in the same directory. Putting a symlink in its place to /cygdrive/c/Program Files/MiKTeX 2.9/miktex/bin/x64/pdflatex.exe (where the relevant MiKTeX binary is) doesn't help. What am I missing here?

It's worth noting that running pandoc main.tex -o main.pdf from the Windows command line seems to work just fine, and gives no UAC prompts. Ideally, I would like a solution where I can run the same installation just as easily from either the Windows or cygwin command line, but being able to run it from cygwin is a must for my workflow (i.e., answers along the lines of "Why even bother with cygwin?" are not acceptable here). It seems there really ought to be a simple way to make this installation available to cygwin.

  • What happens at the Cygwin command line for, e.g. pdflatex --version? – Joseph Wright Aug 14 '14 at 6:00
  • @JosephWright pdflatex --version in cygwin returns "pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014/Cygwin) kpathsea version 6.2.0". Having looked through other answers, I'd installed the texlive and texlive-collection-latex packages in cygwin, to no avail. – Tim Parenti Aug 14 '14 at 15:26
  • Maybe it's because symlinks in windows work differently than in linux, just guessing. Have you tried of the full path to to pdftex.exe into the makefile instead of the symlink? – kristjan Aug 14 '14 at 16:54
  • @kristjan Yep, no luck with that either. I've tried just about every permutation of full and partial paths, both UNIX and Windows styles. – Tim Parenti Aug 14 '14 at 17:05
  • 1
    did you try with no path at all? It looks odd that you use absolute pathes in the makefile for pdflatex but not for pandoc. And why do you bother with miktex when you have texlive 2014 in your cygwin? – Ulrike Fischer Aug 15 '14 at 7:52
3

The following command worked for me, under cygwin. I installed pandoc 1.13.2 and MiKTeX 2.9.5105 64-bit. Then I ran:

pandoc -s \
--latex-engine='C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe'  \
-f markdown_github -t latex \
"my-file.md" -o "my-file.pdf"

The key here is that I gave the full path for MiKText's pdflatex.exe in the --latex-engine key, in quotes, using the windows path (as the pandoc I installed is the windows pandoc, it requires windows-style paths to find resources).

I used -f markdown_github because of the file format of my-file.md

I used -t latext but that's optional AFAIK.

  • I was having this same problem as OP when trying to run pandoc in a git post-commit hook to convert markdown to PDF. Setting the --latex-engine="C:/Program Files (x86)/MiKTeX 2.9/miktex/bin/pdflatex.exe" in my pandoc call did the trick. – Chad Cooper Aug 12 '15 at 16:00
1

Thanks to Ulrike Fischer's comment, I realized that trying to get the Windows-based MiKTeX installation to play nicely with the cygwin-based pandoc installation was a fool's errand. Best to keep those things separate.

So, with texlive installed in cygwin, I was left with a much simpler solution:

PANDOC= pandoc
pdf:    main.tex
    $(PANDOC) main.tex -o main.pdf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.