[Tex/LaTex] Making MiKteX pdflatex on Windows available to cygwin

cygwin;makefilemiktexpandocwindows

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.

Best Answer

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.