16

This question already has an answer here:

I'm trying write a report in LaTeX but TeXstudio won't let me. All I have is this:

\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx}

\title{----}
\author{---\\By: ----}

\begin{document}

\maketitle
\paragraph{1}
\paragraph{2} 
\subparagraph{Red}$\\$
\includegraphics{Red}
\subparagraph{Blue}$\\$
\includegraphics{Blue}

\end{document}

But when I click F1 to compile, TeXstudio spits this message:

Error: Could not start the command: pdflatex.exe -synctex=1 -interaction=nonstopmode "Prelab1".tex

What is the problem? Why can't I compile?

P.S: Ever since I switched from Ubuntu back to windows, writing LaTeX documents has been a massive pain T.T. What is the best LaTeX editor that won't give me a problem every single second?

marked as duplicate by user170109, Raaja, Stefan Pinnow, Phelype Oleinik, siracusa May 6 at 13:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Can you compile the file from the shell (i.e. pdflatex Prelab1)? Seems like you distribution is not correctly set up. – Qrrbrbirlbel Feb 13 '13 at 22:37
  • 1
    @Qrrbrbirlbel i'm super new to latex so "compile the file from the shell" makes no sense to me. What exactly should I do? – Richard Feb 13 '13 at 22:39
  • Shell means for Windows: Command line. Open up a window with one and cd to your TeX file and compile your document from there with pdflatex Prelab1. This tests if your TeX distribution is correctly installed at all. – Qrrbrbirlbel Feb 13 '13 at 22:47
12

Check if the configuration is correct and that TexStudio points to the program binaries.

Wtih Windows PC: Options> Configure TeXstudio, select Build, option Default Compiler.

With OSX: texStudio > Preferences, select Build, option Default Compiler.

screenshot for OSX

As for your question about the best editor, there is a Comparison of TeX editors documented on Wikipedia, which may be of use to you.

  • where is this quick build? This is what I see i.stack.imgur.com/rHtbU.png – Richard Feb 13 '13 at 22:44
  • still don't see a quick build, i.stack.imgur.com/WZtFc.png – Richard Feb 13 '13 at 22:48
  • 1
    I just edited my post. I hope the change helps. – Umar Kalim Feb 13 '13 at 22:55
  • @UmarKalim again, on windows there is no quick build option – Richard Feb 13 '13 at 22:57
  • @Richard, my apologies. I googled a bit and it seems that the options should be under the Build Tab, as is the case in the screenshot for OSX. Also, as suggested by @Qrrbrbirlbel, testing over the command line pdflatex PreLab1 would ensure that your TeX setup is functional. – Umar Kalim Feb 13 '13 at 23:10
9

Another reason for getting this error with TexStudio (which is a wonderful IDE IMHO), is that it is really trying to tell you that the .tex file does not exist. This can happen, for example, when the wrong file has been chosen as the Master document. Check the error message to see that the file it mentions is the correct master. e.g.

pdflatex.exe -synctex=1 -interaction=nonstopmode "wrongfile".tex

or

pdflatex.exe -synctex=1 -interaction=nonstopmode "rightfile"."wrongextension"
  • 1
    In this case, check under Options/Root document if a root document has been selected and/or search for the "magic command % !TeX root = in your .tex document. This magic command tells TXS which master document to consider. – ebosi Apr 30 '17 at 1:19
4

I tried following the advice given here but nothing worked, even reinstalling TexStudio and Mactex didn't work. I had to go to:

TexStudio -> Options -> Restore default settings ...

Seems like a reinstall kept some preferences that I had corrupted.

  • This is the only thing that worked for me! Thanks! – daviewales Oct 11 '17 at 9:52
4

Well I am unable to comment on pdmadscience's comment. I just wanted to extend his response here. I had the same issue as the original poster and adding the pdflatex command (like pdmadscience suggested) fixed the issue. In the TexStudio documentation, they also add a few switches so that the full command looks like this:

"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex" -synctex=1 -interaction=nonstopmode %.tex

(Assuming MikTek was installed in C:\Program Files)

You can also add C:\Program Files\MiKTeX 2.9\miktex\bin\x64\ to your PATH and replace "C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex" with just pdflatex.

Here is the screenshot from the documentation:

No commands
(source: sourceforge.net)

2

If you installed texlive 2017 using official install-tl script on x64 linux, you can set path in tex editer to /usr/local/texlive/2017/bin/x86_64-linux.

enter image description here

1

I had the similar problem, but I solved it by change the path in Commands, see it in the picture. In it, you only need to correct the path to PdfLaTeX.

Hope this would help.

1

For me reinstalling MikTex solved the issue.

I had to delete this folder since it complained that the target directory is not empty

C:\Users\Haider\AppData\Local\Programs\MiKTeX 2.9
0

I had this same problem on Mac and fixed it by going to texStudio > Preferences > Commands and changing the text next to PdfLaTeX from pdflatex -synctex=1 -interaction=nonstopmode %.tex to /Library/TeX/texbin/pdflatex -synctex=1 -interaction=nonstopmode %.tex. Specifying the entire path in the command fixed it for me.

(Use the command which pdflatex in the terminal to see what the path is on your machine).

-1

I just installed TeXStudio and found I had the same issue. Running "Build and view" opened the view window, but nothing came up and the message I received was that the view failed because the pdf file did not exist. I read one of the other previous responses to this question, and thought I would build upon it with a little more detail: I looked in the configuration settings and found that the initial installer had not set up the vast majority of the commands:

No commands

I fixed the issue by pointing to the pdflatex.exe, with with my distribution was under

<Drive>:\Program files\Miktex 2.9\miktex\bin\x64\pdflatex.exe

If you do not find the file here, I would just search for "pdflatex" in windows.

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