0

How can I compile some LaTeX source into PDF and keep the LaTeX source as some meta-information in the PDF? (or somehow embedded otherwise in the way that it is easy to retrieve the LaTeX source while having the option not to view it when reading the PDF)

  • 4
    you can use the packages embedfile or attachfile2 – Ulrike Fischer Dec 4 '19 at 18:15
  • See also package embedall. – ShreevatsaR Jan 4 at 3:30
0

This might be a bit of a hack, but you can edit pdf files directly. If it was a short amount of text, you can just open the pdf file in a text editor such as vim and write a comment, e.g. "%This file was written by Batman". However, that wouldn't be generated every time you compile the latex document.

An alternative could be to add something to a makefile (if you are using a makefile to compile the document) that appends the string you want to the output pdf file.

| improve this answer | |
  • You will break the xref table (and with it the pdf) if you do this. You can only replace bytes not add some. – Ulrike Fischer Dec 5 '19 at 7:04
  • Interesting, thanks for pointing that out. It might work if the pdf was produced with >= v1.6 which doesn't use an xref table (although, it might still break). One can force pdflatex to produce a pdf with v1.7 with "\pdfminorversion=7". – user29449 Dec 5 '19 at 13:59
  • sorry? Where in the reference do you find that there is no xref in newer pdf? If you had tried and looked you would have found the startxref entry with the byte offset at the end of the pdf. – Ulrike Fischer Dec 5 '19 at 22:12
  • @UlrikeFischer I think it should be possible to add comments after the trailer. That does not change the byte offsets. – Henri Menke Jan 4 at 4:29

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