How can I recover my .tex file after a computer crash?

In summary, the keyboard and mouse stopped working, but the tex file still had some characters typed in. When I tried to compile it, the software said there was nothing to compile because the tex file was too large. I found a more fancier editor that could tell me more about what was in the file, and I just retyped everything. This could have been a lot worse.
  • #1
JonnyG
234
45
I was doing some work using Texmaker and my all of a sudden my keyboard stopped working and my mouse stopped working. But I know that I had just saved the file, so I restarted my computer. But now when I open up the .tex file to continue my work it is completely blank. It says that I have about 20000 characters typed, but when I try to compile it into a .pdf it says that there is nothing to compile. Is there any way that I can reverse this? Luckily I have a .pdf of my work already saved, so I haven't lost all of my work, but it will be a pain to retype all of it again. Is there perhaps a way to start a new .tex file and when I compile that into a .pdf, have it combine with the other .pdf to make one file?
 
Computer science news on Phys.org
  • #2
What is the size of the tex file reported by the OS?

Isn't tex file just a text file, just with another extension?
 
  • #3
The size is 19 kb. Larger than a blank file. As to your other question, I have no idea. I do not know much about this stuff. But there are other files associated with .tex file, there is a .bak file and a .aux file. There is also a .txt file, but that just seems to be an error log from the compiler (if that makes sense).
 
  • #4
Try to open the file just with a notepad.
 
  • #5
JonnyG said:
there is a .bak file
That is not a standard LaTeX file, so it is probably a backup. Copy it to another name with an extension .tex and see what it looks like in Texmaker.
 
  • #6
When I open it up with a notepad, it is just blank. When I copy the .bak file to another name and change the extension to .tex it opens up to a blank file. But when I open up my original .tex file in Texworks, another LaTex program, it opens up two windows. The window for the source code is blank, but the window which shows the output has my work.
 
  • #7
Is it possible to recover the file by doing a system restore?
 
  • #8
It's a large text file with blank characters?
Try a fancier editor (like Notepad++) that might be able tell you more about what is in your file.
Could notepad be choking on a weird character, fooling itself into thinking the file is done and showing you nothing more?

Whatever you do, don't delete anything or empty the trash.

You might try to search your entire computer (with Explorer or something fancier)
for files created within (say) the last 24 hours with size less than 100k.

If you know where temporary files are stored by the software,
you might be able to limit your search to those places.
(Note that those places may be buried in folders that are hidden by default.)

[In the future... it might be a good idea to periodically back up your work.
In my setup, I have a script that adds a timestamp to the filename of a file I select, which I periodically invoke.
It's too complicated to replicate my setup...
but you might be able to find something (or write your own)
with help from https://www.google.com/search?q=attach+timestamp+to+filename
https://www.google.com/search?q=attach+timestamp+to+filename+windows ]
 
Last edited:
  • #9
Thanks for all of the replies. There wasn't THAT much work done yet and I have the .pdf, so I just retyped everything. I learned a valuable lesson about backing up my work though. This could have been a lot worse.
 
  • Like
Likes DrClaude
  • #10
robphy said:
Try a fancier editor (like Notepad++)

Just installed it, nice editor. Thank you Robphy.
 

FAQ: How can I recover my .tex file after a computer crash?

1. Can I recover a .tex file if I accidentally deleted it?

Yes, you can often recover a deleted .tex file by checking your computer's trash or recycle bin. If it is not there, you can use file recovery software or contact your IT department for assistance.

2. Is there a way to recover a .tex file if it was not saved?

Unfortunately, if a .tex file was not saved at any point, it cannot be recovered. It is important to always save your work periodically to avoid losing progress.

3. How can I recover a corrupted .tex file?

If your .tex file is corrupted, you can try using file repair software designed specifically for .tex files. You can also try opening the file in a different text editor or contacting your IT department for assistance.

4. Can I recover a previous version of a .tex file?

If your .tex file was saved and edited multiple times, you may be able to recover a previous version using version control software or by checking your computer's backup files. However, this is not always possible and it is important to regularly save and backup your work.

5. How can I prevent losing my .tex file in the future?

To prevent losing a .tex file, make sure to regularly save your work, use version control software, and backup your files on a separate storage device or in the cloud. It is also important to have a reliable antivirus program to protect against file corruption or deletion.

Back
Top