4

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?

6
  • 2
    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, 2016 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. Sep 15, 2016 at 6:02
  • 1
    Possible duplicate: How to convert PDF to (La)TeX?
    – Werner
    Sep 15, 2016 at 6:06
  • 1
    also yesterday's tex.stackexchange.com/questions/329566/… Sep 15, 2016 at 6:53
  • 1
    Pro-tip: LaTeX source files are small, unlike DOCX or similar stuff. Always store them in Dropbox or another cloud service. :) Sep 15, 2016 at 13:56

2 Answers 2

16

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:

(Edit 2020: the filecontents package is a no-op now as its features have been moved into latex itself with some changes: The example will no longer overwrite existing files, unless a specific option is used: \begin{filecontents}[overwrite]{testoverwrite.tex}).

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

    \end{filecontents}
    \begin{document}
     blblb
    \end{document}
  1. Other applications can destroy files too - by accident or by (evil) purpose.

  2. 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.

3

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.

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

You must log in to answer this question.

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