How to recover a .tex file?

  • Thread starter JonnyG
  • Start date
  • #1
225
22
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?
 

Answers and Replies

  • #2
Borek
Mentor
28,635
3,106
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
225
22
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
Borek
Mentor
28,635
3,106
Try to open the file just with a notepad.
 
  • #5
DrClaude
Mentor
7,554
3,894
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
225
22
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
225
22
Is it possible to recover the file by doing a system restore?
 
  • #8
robphy
Science Advisor
Homework Helper
Insights Author
Gold Member
5,778
1,078
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
225
22
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
Imager
Gold Member
98
53
Try a fancier editor (like Notepad++)
Just installed it, nice editor. Thank you Robphy.
 

Related Threads on How to recover a .tex file?

  • Last Post
Replies
2
Views
872
Replies
8
Views
1K
  • Last Post
Replies
2
Views
2K
Replies
3
Views
1K
Replies
5
Views
3K
  • Last Post
Replies
3
Views
5K
  • Last Post
Replies
10
Views
2K
  • Last Post
Replies
21
Views
2K
Replies
7
Views
102K
Top