TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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?
share|improve this question

migrated from stackoverflow.com Oct 11 '13 at 21:08

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Fran, Werner, Thorsten, Torbjørn T., m0nhawk Oct 12 '13 at 6:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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.

share|improve this answer

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

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