0

On my windows company machine I would like to setup LaTeX with Emacs. When I try to compile a .tex file I get the following error:

Running `LaTeX' on `report' with ``pdflatex -file-line-error -interaction=nonstopmode "report.tex"'' 'pdflatex' is not recognized as an internal or external command, operable program or batch file. 

I found this question on this forum. That is why I have tried to add the location of miktex bin folder to path in my init.el:

;;;; TEXT MODE (add-hook 'text-mode-hook 'turn-on-auto-fill) (add-to-list 'exec-path "C:/Program Files/MiKTeX/miktex/bin/x64/") 

However after restarting emacs I don't see it added to the PATH, M-x getenv Ret PATH Ret leads

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Python39\Scripts\;C:\Program Files\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\blp\DAPI;C:\blp\DAPI\DDE 

What am I doing wrong to get the emacs recognize miketex's pdflatex?

2
  • Try (setenv "PATH" (concat "Write its directory down here" path-separator (getenv "PATH"))) Commented Apr 13, 2023 at 9:12
  • @Shynur worked, many thanks! if you put it as an answer, I will gladly accept it :) Commented Apr 13, 2023 at 16:33

1 Answer 1

2

I don't see it added to the PATH

It is because exec-path is a variable in the Emacs Lisp world.
C-h v exec-path:

a variable defined in ‘C source code’.

Whereas PATH is not a concept from Lisp.

They are different things.


How to add miktex pdflatex to PATH

Use setenv to modify it (and other environment variables as well):

(setenv "PATH" (concat "Write its directory down here" path-separator (getenv "PATH"))) 

There is one place worth noting; that is path-separator.
For portability, its value depends on platforms. On MS-Windows it is a semicolon.
My advice is to never write it by hand.


You can also find relevant and useful information on 李杀(Xah Lee)'s website.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.