17

I just installed MiKTeX and TeXstudio, but when I try to compile a document I get the following error:

Error: One command expansion invalid.

Make sure that you have installed a (La)TeX distribution e.g. MiKTeX or TeX Live, and have set the correct paths to this distribution on the command configuration page.

A (La)TeX editor like TeXstudio cannot work without the (La)TeX commands provided by such a distribution.

I did some Googling, and found where I needed to go, and in options -> configure LaTex -> Commands -> LaTex, I have the following:

"E:\Program Files\MiKTeX 2.9\miktex\bin\x64\latex.exe" -src -interaction=nonstopmode %.tex

(the file path is correct, I double- and triple-checked) Can someone tell me what I'm doing wrong?

4
  • 2
    Can you compile from the command line?
    – Bernard
    Commented May 22, 2015 at 0:26
  • 1
    can you also try putting "%.tex" ? (I mean with the straight quotes like the latex.exe path. I'm wildly guessing by the way.
    – percusse
    Commented May 22, 2015 at 0:43
  • When I input pdflatex Libraries\Documents\ch1demo.tex into the command line, it returns the error "I can't find file pdflatex".
    – kgrafton
    Commented May 22, 2015 at 0:49
  • 1
    That actually helped me find the answer - I needed to give TeXstudio the filepath to pdflatex. Thank you!
    – kgrafton
    Commented May 22, 2015 at 0:52

2 Answers 2

8

I was getting the same error. Fixed for me by explicitly filling-in all the paths as shown... enter image description here and enter image description here

2
  • 2
    That should not be necessary. It is often a sign that the path variable have not been set up correctly
    – daleif
    Commented Sep 5, 2015 at 19:50
  • 3
    Please add to your answer that the path a dependend of the used system. So your solution must not be the right one for an other reader ... BTW: better would be to write the pathes, showing them in an images makes coppying not easier ...
    – Mensch
    Commented Sep 5, 2015 at 20:05
8

This is probably because the MiKTeX is installed in a different directory than the TeXstudio. For example, if you choose default settings, MikTex is under x64 folder while TeXstudio is under x86 folder.

The best way is to manually install them in the same directory otherwise you will have to set the configuration line by line. I fixed this by reinstalling TeXstudio and then it linked to MiKTeX on the first trial. Hope it helps

1
  • 1
    I just tried this and it worked. By default on windows, MiKTeX installs into AppData. Instead, install it in Program FIles (x86) and then reinstall TeXStudio. It then finds MiKTeX and auto configures everything. Commented Jan 21, 2016 at 10:02

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