10

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?

5
  • 1
    That's really not a good idea. Better send a zip file. Sep 3, 2012 at 13:12
  • 4
    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. Sep 3, 2012 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, 2012 at 13:21
  • 1
    @DavidCarlisle: Make your comment to an answer, then there's no need for closing/deleting!
    – Speravir
    Sep 3, 2012 at 14:06
  • @Speravir answer added Sep 3, 2012 at 14:11

4 Answers 4

10

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.

3

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

6
  • 3
    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... Sep 3, 2012 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? ;-) Sep 3, 2012 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. Sep 3, 2012 at 14:06
  • 1
    @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, 2012 at 14:21
  • 2
    @percusse It wasn't my understanding that the PDF was supposed to be distributed; only the sources. Sep 3, 2012 at 14:34
1

Inline encoding of images in LaTeX files isn't for human usage, it's for writing converters. Right now, any converter into LaTeX clutters the current directory with images or subdirectories, often containing large numbers of tiny files. People need to remember to remove them and copy them when they move the converted file around. It would be nice to have an alternative to this.

1
  • Welcome to TeX.sx!. It is worth while to expand/add more value with examples or demonstration with alternative approaches to existing answers. Apr 6, 2013 at 23:38
1

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

2
  • 1
    That link doesn't seem to exist anymore??
    – user53964
    Oct 24, 2014 at 13:07
  • Shoot, that's too bad. I looked around and he also seems to have written the answer in response to a tex.sx question here: stackoverflow.com/a/1921858/743730
    – mhucka
    Oct 29, 2014 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .