Is there some way to embed LaTeX source code in a PDF file?
I would recommend the embedfile
or the navigator
package (the latter has the additional advantage of working together with dvipdfmx
, see this question of mine). Both are quite similar in usage:
With the embedfile
package:
\documentclass{article}
\usepackage{embedfile}
\embedfile{\jobname.tex}
\begin{document}
The document
\end{document}
With the navigator
package:
\documentclass{article}
\usepackage{navigator}
\embeddedfile{sourcecode}{./\jobname.tex}
\begin{document}
The document
\end{document}
You can attach arbitrary files to a PDF document using the attachfile2
package.
The above package works only with pdfTeX and dvips
. For a XeTeX/xdvipdfmx
solution, see this question.
You can do this in ConTeXt as well. Example:
\setupinteraction [state=start]
\starttext
Foo \attachment[file=attachfile.tex, title=Some file, author=Me]
\stoptext
The file
key contains the file name, the title
key is used (probably depending on the reader) e.g. for a tool tip (see screenshot). Interaction needs to be activated, otherwise the attachment mechanism don't work.