# The latex file coding is not there but the pdf file is there

I wrote all my coding in the .tex file. The next day when I opened it the coding is all gone and the pdf file is opening with it and is displayed as an output. How do I bring back my coding?

• This is going to be an editor or PC issue: TeX itself won't delete the content of input files. We'll do our best to help if you can give us more detail, but the first question has to be 'Do you have a backup'? – Joseph Wright Sep 15 '16 at 5:57
• I don't have the backup of the coding. Like I opened the latex file and along with it the pdf version is also opened with all the text, but the latex file has no coding. Is there a way to retrieve back the coding because the pdf file is opening. – Zainab Saeed Sep 15 '16 at 6:02
• Possible duplicate: How to convert PDF to (La)TeX? – Werner Sep 15 '16 at 6:06
• also yesterday's tex.stackexchange.com/questions/329566/… – David Carlisle Sep 15 '16 at 6:53
• Pro-tip: LaTeX source files are small, unlike DOCX or similar stuff. Always store them in Dropbox or another cloud service. :) – Andrea Lazzarotto Sep 15 '16 at 13:56

As the question pops up rather regularly I will try to answer.

1. It is possible to destroy files and content when running LaTeX. LaTeX has to write a lot of files (.log, .aux, .toc, etc) and it must be able to overwrite them, so it needs the rights to overwrite existing files. This here e.g. will "destroy" testoverwrite.tex -- even if this is the name of the running file:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{testoverwrite.tex}

\end{filecontents}
\begin{document}
blblb
\end{document}

2. Other applications can destroy files too - by accident or by (evil) purpose.

3. Errors can destroy files, e.g. some synchronization going bad, failure of power, failure of your hard disk, or too fast typing (ctrl+A + delete).

This all means that backups are important. If you spent hours on a document you should regularly store a copy in some other place.

The pdf output of LaTeX is not a good backup: At first it misses all the important coding. At second it changes at every compilation and so can be destroyed very fast.

If you don't have a backup (which happens once in a while to everyone) and you suddenly miss a file or some content it is important to do nothing rash: Most editors have a temporary backup somewhere (often with the ending .bak) but if you change something it can be lost. Copy all files that could be helpful to some usb stick or some other place. Check where your editor perhaps stores its backups and copy them too. If you are using some cloud space: They often have a version control system so check if you can retrieve an older version of the file from there.

I just encountered this issue, using Texmaker on Linux, and the problem turned out to be that I was out of hard drive space. There wasn't enough room to save the new file, so Texmaker saved a blank file in its place.

• Wow that's pretty awful design. Are the Texmaker developers aware of this bug, does anyone know? – ShreevatsaR May 9 '17 at 16:46