[Tex/LaTex] Is there some way to embed LaTeX source code in a PDF file

attachfileembeddingpdfsource

Several times now I have inadvertently lost the .tex file that generated a PDF file with pdflatex. Given what I know of the internal structure of PDF files, it should be possible to embed a text file containing the original LaTeX file into the PDF file so that it can be extracted later.

I am aware of no technology for doing this, but perhaps you are. Does anybody have something like this?

Best Answer

The package embedall has been made exactly for that:

Just include

\usepackage{embedall}

just before \begin{document} and it will embed all graphics, listings, and the tex source.

side note: The CTAN tag archival has more related tools listed. For instance, mkjobtexmf saves all .sty files. They could be embedded in the PDF, but I am unsure whether that's overkill. The package skb proposes a new kind of workflow, which does not really seem to tackle your issue.

Related Question