# Is there a way to create a standalone folder/document with non standard packages?

I am working on an article which will be compiled on another machines (of somebody else). I don't want to depend on the other person to install missing packages. Is there a way to include them with the folder I'll send him?

• You can download the packages from CTAN and put them (and compile them) in a directory of your project and include them from there. But I think you don't want to download the packages one-by-one. Do you want this to be done automatically? – masu Jan 7 '14 at 9:35
• @SándorKazi What do you mean by "done automatically"? – Yotam Jan 7 '14 at 12:14
• Automatically, so you don't want/have to download the packages one-by-one manually. I don't think it is possible, but is that what you want? – masu Jan 7 '14 at 13:23
• Do you want something like ctan.org/pkg/bundledoc with ctan.org/pkg/snapshot? Or maybe ctan.org/pkg/arlatex? – cfr Jan 8 '14 at 0:19
• @SándorKazi Yes, exactly – Yotam Jan 8 '14 at 12:02

I've answered a similar question before (see here), but maybe you just want to give them one file rather than a whole archive containing all the files. If so, this is one possibility, assuming this 'projectfile.tex':

% projectfile.tex
\RequirePackage{snapshot}% <-- this *must* be used!
\documentclass{article}
\usepackage{parskip}%      <-- pretend this is a file your partner doesn't have
\begin{document}
Some words.
\end{document}


Now, you run latex (or pdflatex, etc.) on projectfile.tex. Among the files created is projectfile.dep (via the snapshot package). Now we want to combine the power of arlatex and bundledoc to create one file that has, via the filecontents package all the files required to successfully process projecttile.tex (i.e., from article.cls to parskip.sty). If you include many packages, this file will get ridiculously big, which is why outputting it to an archive file probably makes more sense. However, maybe size isn't an issue....

Next we need a .cfg for bundledoc. For Windows, the variables will be slightly different, but this is what I used (let's call it arlatex+bundledoc.cfg):

# config file 'arlatex+bundledoc.cfg'
bundle: (arlatex --document=$BDBASE.tex$BDINPUTS > $BDBASE-all.tex) sink: > /dev/null 2>&1 find: kpsewhich -progname=latex$BDINPUTS


Now we run the bundledoc command (--verbose might be a good idea, at least when you're starting out):

bundledoc --config=arlatex+bundledoc.cfg --verbose projectfile.dep


This should create a file called projectfile-all.tex. Test it by running latex (etc.) on it and diff-ing the resulting output with the output of projectfile.tex.

As I said, this process is likely to create monster files, so it probably makes more sense to output to a compressed file of some sort (see the other answer), or simply use arlatex to include the specific files that are needed for portability.

Edit:

In other words, the basic procedure involves these steps:

1. Create your file as you normally would (e.g., via pdflatex);
2. When you are ready to use bundledoc, add the line \RequirePackage{snapshot} at/near the top of your .tex file (must be above the \documentclass line);
3. Compile main .tex once again to create the .dep file;
4. Ensure you have a viable config (.cfg) file for bundledoc (easiest to keep it in the working directory);
5. Run bundledoc with the .cfg file on the .dep file

If all goes well, and if you used file names similar to the ones in this example, you will end up with a file called -all.tex.

A combination of bundledoc and snapshot may meet your requirements. Although I've not used these myself, as I understand it snapshot can make a list of all the files and packages required to compile your document. bundledoc can then gather those files and packages together so that they can be easily bundled with your document for sharing with others.