Include source code of pdf picture directly into LaTeX file

Suppose you have a (PDF)LaTeX file where you include pdf pictures via `\includegraphics`.

Now, if you want to share the LaTeX file with another person, you always have to send not only the LaTeX file itself but also all the included pdf files containing the pictures. This is pretty inconvenient for recipient.

It would be much more comfortable to copy the pdf source code right into the LaTeX file so that only one file has to be sent. Is that possible?

-
That's really not a good idea. Better send a `zip` file. –  Stephan Lehmke Sep 3 '12 at 13:12
Most recipients shouldn't find it inconvenient to receive a zip file of all the needed files? The alternative would be to (for example) base64 encode the pdf file so it is all safe characters and put it in a `filecontents` environment in the latex file and then specify a graphic rule which base64 decodes the file that latex will then write. But then you have to make sure the recipient's latex setup allows calling external scripts (and that they have a necessary decoder) which is harder to setup usually than simply unzipping an archive. –  David Carlisle Sep 3 '12 at 13:14
Ah, OK. Wasn't aware it's so difficult. Then of course a zip file seems to be more convenient. Then, maybe one could think of closing/deleting the question!? @moderators: Feel free to do so. –  lpdbw Sep 3 '12 at 13:21
@DavidCarlisle: Make your comment to an answer, then there's no need for closing/deleting! –  Speravir Sep 3 '12 at 14:06

Most recipients shouldn't find it inconvenient to receive a zip file of all the needed files?

The alternative would be to (for example) base64 encode the pdf file so it is all safe characters and put it in a `filecontents` environment in the latex file and then specify a graphic rule which base64 decodes the file that latex will then write. But then you have to make sure the recipient's latex setup allows calling external scripts (and that they have a necessary decoder) which is harder to setup usually than simply unzipping an archive.

-

You can use the `attachfile` package. Abstract:

This package defines an `\attachfile` command that lets you attach arbitrary files to a pdf document. These files are embedded right in the pdf file, so they get transmitted along with it. The package also gives you control over the corresponding icon's properties and various other associated metadata.

So, you can attach all files needed ((La)TeX source, PDF images or a zip archive) into your PDF file.

(Obviously, if you want to group only sources LaTeX and PDF images without the resulting PDF file, David Carlisle's answer is more appropriate.)

-
That's a bit indirect, isn't it. As the main purpose here is not the PDF file but the LaTeX source, it seems a bit like abusing PDF as an inferior `zip` format... –  Stephan Lehmke Sep 3 '12 at 13:39
@StephanLehmke It is very practical in many cases : in a tutorial for example... Do you think the PDF format is of inferior quality than the ZIP format? ;-) –  Paul Gaborit Sep 3 '12 at 13:49
Well it's not mainly meant for storing files, is it? A larger document might include thousands of files; there I'd rather trust a dedicated file format. –  Stephan Lehmke Sep 3 '12 at 14:06
@StephanLehmke If it's only the source code of the PDF file, I find it better than carrying a zip file around since one doesn't need to extract or open the zip file for the PDF file. And the source code can be extracted whenever needed. –  percusse Sep 3 '12 at 14:21
@percusse It wasn't my understanding that the PDF was supposed to be distributed; only the sources. –  Stephan Lehmke Sep 3 '12 at 14:34
show 1 more comment

4 years ago, someone by the name of Mike Ashley posted a GitHub gist that exactly solves the OP's original problem.

-