15

Im new to latex and sometimes I get this error message:

line 5: ! I can't write on file 'MasterThesis.pdf'. Please type another file name for output! Emergency stop.<to be reaad again>... ...\end{document}
Line 1: !==> Fatal error occured, no output PDF file produced!

Today when I got this message nothing seems to work to fix it. I have tried the following:

  • Installed a new editor which gives the same error (TeStudio and TexMaker)
  • Deleted all files except the tex file
  • Close all programs and processes in task manager that seems to be PDF-related
  • Restart the editor (TexMaker)
  • Reboot the computer
  • I got several GB left on the disk drive
  • Searched through the internet to find a solution
  • Rename the tex file to only letters (no spaces, dots, symbols, etc)
  • Change the name of the folder that contains the file

Last thing I did was to remove everything in the tex file (with backup of course) except for the following:

\documentclass[12pt, a4paper]{article}

\begin{document}
    Hello
\end{document}

But I still get the same error.

If I create a new empty file it manage to compile. Then I paste my work into it and the error occures. So I press ctrl+z a couple of times to undo until I reach the document that works but then the error is still there Im using Windows 8 and TexMaker.

Im working on my master thesis and it's very frustrating when I can't continue my work. Could someone please help me with this?

7
  • Welcome to TeX.SX! Apr 27, 2015 at 13:59
  • 9
    are you using acrobat to view the pdf? that locks the file. most other pdf readers do not do that. Apr 27, 2015 at 14:03
  • Acrobat Reader is not installed. Im using "PDF-XChange Viewer". How could I stop it? I never opened the file in PDF-XChange Viewer. Apr 27, 2015 at 14:07
  • I have an app named reader which was installed on my computer when I bought it but I don't think I can remove it. Apr 27, 2015 at 14:29
  • @JesperLundin Try this. In TexMaker, go to options, and select the embedded viewer. This viewer, internal to TexMaker, should allow you to compile and view. Per Acrobat 'reader/viewer', because it holds file handles you have to actually close the viewer after each usage of the reader if any other process needs to use that file in Windows. Apr 27, 2015 at 15:22

4 Answers 4

10

I had the same problem. If you use Adobe Acrobat reader X, go to the Preferences of Acrobat Reader. In the menu Security (Enhanced) deselect Protection and Protection Enhanced OR add the Folder Path of your pdf folder build with latex.
That's work with me !

3
7

The most common reason for the error "can't write to filename.pdf, save it to different name" that I observed during my works is because I've kept open the PDF file generated by quick-building the LateX file.

I mean if the pdf file was kept open, that was generated in the same directory (same folder) as the latex file, then LateX shows error. Try closing that opened pdf and then build your LateX file. It works!

1
  • 1
    This holds for some PDF viewers including Acrobat but not for others like Sumatra and Okular. The difference is that some PDF viewers lock the file to prevent it being changed while it is open in the viewer, for compiling latex this feature tends to be a nuisance as noted.
    – Dai Bowen
    Oct 8, 2016 at 12:05
5

I found the problem thanks to https://www.overleaf.com. I created an account an pasted my code and it resulted with an error in a tikz figure, I forgot to put an semicolon, " ; ", in the end of a line which caused the program to not compile which also resulted in errors in other tex files that were not related to the one with the error. Many thanks to a friend on facebook who responded to my post on facebook about this problem.

1
  • In general it always good to undo until last time it worked and examine the changes one by one. Apr 28, 2015 at 12:22
5

I know this is not the answer to your question, but I sometimes also get that error.

If you work with a cloud drive such as Google Drive or Dropbox you often run into problems because the cloud starts syncing before writing to all the files is done.

The bigger your tex file, the longer it takes to compile, and the bigger your chances of encountering this type of error

A solution (If that is the problem) would be to stop the syncing with the cloud for the period of compiling.

You must log in to answer this question.

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