I often make some pdf files (not so long) using LaTeX. I often need to later modify these files and I often can not do this because I lost the tex source file. You will say: "Be more careful!"....

Leaving out jokes, I am thinking of a way of creating a pdf file with included the LaTeX code for generating it, but I don't know how to do it (I do not even know if it is possible). The only thing I can imagine is to save the code in the pdf metadata but I don't know how much space they can occupy and a problem is that I would like also to preserve the spacing of the code (indentation and breakline).

So my questions are:

  1. Do you think using metadata is a good idea? What about the size (disk space) and the spacing of the code?
  2. Have you any other idea to do it?
  • TeX files are very small, they are consistently smaller than their output. Unless your document contains many images, you won't notice a size increase. I would caution against distributing your files like this, though. – Sean Allred Nov 12 '13 at 6:35

Use the attachfile package to include the source code tex file as an attachment to the PDF.

| improve this answer | |

You should keep your TeX files under revision control so that you won't lose them so easily.

| improve this answer | |
  • Addendum: TeX files under revision control and backed up on the cloud. – Sean Allred Nov 12 '13 at 6:33
  • No, “the cloud” is not a backup. If you treat it as such, your data will be lost. – mirabilos Aug 13 '15 at 9:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.