Skip to content
Math Solves Everything
  • Matlab
  • Math
  • Linear Algebra
  • Calculus
  • Tex/LaTex
  • GIS

[Tex/LaTex] recover the .tex file

auxiliary-filesconversionmetadata

I have lost my tex file but I still have my pdf, .aux, .bak, .bbl, performance monitor file, and my text document.

Can anyone tell me if I can restore my .tex file from this? In any form?

Addition by Jake:
Note that this question is not a direct duplicate of How to convert PDF to (La)TeX?, since that question is concerned only with converting PDF to .tex without any of the additional files that are available in this case.

Best Answer

Broadly, the problem outlined here is the same as How to convert PDF to (La)TeX?. The reason is that at best the various additional files contain only a small subset of the information needed to understand the structure of the .tex source file. I don't want to repeat all of the info in File extensions related to LaTeX, etc, but as a summary:

  • The .log and .blg files are logs: they tell us what happened in the LaTeX and BibTeX runs, respectively. That will be useful in working out which packages were used in the .tex file, but that alone does not get us very far (no custom settings or actual input).
  • The .bbl file may help with the bibliography part of the document. If you did not using biblatex then the .bbl file is a formatted bibliography, but if you used biblatex then it's not. Moreover, it does not help with the citations that link to the bibliography, and most of the time the bibliography will be a relatively small part of the entire document.
  • The .aux file tells us about information transferred between LaTeX runs, so for example labels used in the .tex file, but not where they might have been cross-referenced, etc.

As you'll see, the amount of information in the various additional files is at best quite limited, and in most real documents will form only a small part of what's needed to reconstruct the .tex source. Thus there will still be a lot of work to do extracting data from the .pdf, and it may well be easier to ignore the other files and 'start from scratch', reconstruction-wise.

Related Solutions

[Tex/LaTex] Can LaTeX be persuaded to produce text output

The underlying solution is of course the same for ConTeXt and LaTeX: you need to have a way of changing what macros do such that they write the correct output rather than typesetting. This is also much the same as tex4ht does. The advantage ConTeXt has is that the macros are provided mainly by one focussed group, and they include the necessary 'back end' to make that conversion easy. To do the same for LaTeX, you need to handle all of the macros that might be present, which is a problem given the number and variety of LaTeX packages. So while in principal it's possible, the implementation is a severe challenge.

(With my 'LaTeX3 hat' on, this is an obvious area to bear in mind when defining an updated format. To do that, you need to have a much more 'regular' syntax and input than is often the case with LaTeX files at present. Again, I think ConTeXt shows how this can be done as it is already good on keeping the input within it's own structures.)

[Tex/LaTex] How to use the aux file

If you want to know what is in the aux-file: Open it in an editor and look it up. Actually every package (and you too) can write something to the aux-file if it want. So the aux-file normally contains quite a lot informations which are very document specific and which would cause troubles in another document.

So if you want to read an external aux-file you must be careful. E.g. an aux-file contains lines which should be written to the toc-file (\@writefile{toc}) which you don't want to process in this case. The xr-package mentioned by Boris e.g. loops through external aux-files and looks for \newlabel commands but ignores everything else.

Related Question