I was confronted with the same issue in a similar project and spent some time understanding the tricks. The fact that MikTeX comes out selected even if you cleaned up the path results from the somewhat exasperating fact (especially for *nix-oriented devs like me and others) that on installing MikTeX, a fairly big number of Windows registry entries is set. The portable MikTeX (win32 only) distro is the sole exception to this. So if you do need MikTeX on board, my advice is just to do what I did:
- uninstall your current MikTeX distro
- cleanup the registry (ccleaner worked out well)
- install the portable win32 MikTeX distro
Now check that your path does include your TeXlive bin directory path again.
If you use pandoc for creating pdf files from Rmarkdown or other markdown languages, a convenient way to work around path issues is to specify the --latex-engine
option and add the full filepath as an argument. Below is a possible command line, adapted from the RStudio IDE:
path/to/pandoc.exe -V papersize=A4 +RTS -K512m -RTS file.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output file.pdf --template path/to/default.tex --highlight-style tango --latex-engine /path/to/pdflatex.exe --variable geometry:margin=1in