# Bundle latex-document to zip or tar

Suppose you have a latex file (say `test.tex`) which a lot of includes (`\includegraphics`, `\include`, `\includepdf`, bibliography files, `\includestandalone` etc.) sometimes with relative, sometimes with absolute path's sometimes with graphics path set or with graphics environment variable etc. Included tex files may also include other files as well.

Is there a script say `bundle tex.tex` which creates a `tar` or `zip` file which contains a directory containing `test.tex` and all includes. This may be flattend i.e. all includes on the same hirarchy level and the includepathes adapted to just filename such that it compiles if it hand it over to someone else. It may be partially flattened (for example with a subdirectory of pictures) or organized in some other sensible way with adapted paths in the sources such that it compiles after unzipping without changing anything.

For example `unzip testbundle.tar` will result in a directory `testbundle` wich contains `test.tex` and all includes such that for example `pdflatex test.tex` works on a other machine without further intervention.

• something like ctan.org/tex-archive/support/bundledoc?lang=en ? – user36296 Jan 11 at 13:27
• – user36296 Jan 11 at 13:29
• @samcarter Thanks, thats very close to what I want. I just tested bundledoc and realized that it doesn't seem to change absolute paths to relative ones. There should also be an option to only include files which are not in the standard texlive tree. – student Jan 11 at 13:38
• Can you test if you can use the `--exclude` option to exclude the location of your tex instalation, something like `--exclude=/usr/local/texlive/*` (this probably won't work, but maybe worth a try) – user36296 Jan 11 at 13:48
• Although I knew a final PDF can embed all source files / components it was not till testing here I can see the potentials of the \embedfile example So simply save 1 PDF with all the components to rebuild (this would avoid all those cases of "how do I rebuild / update my corrupted tex from just this pdf.") – user170109 Jan 11 at 14:17