8

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?

Yotam
  • 7,109
  • 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 07 '14 at 09:35
  • @SándorKazi What do you mean by "done automatically"? – Yotam Jan 07 '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 07 '14 at 13:23
  • Do you want something like http://ctan.org/pkg/bundledoc with http://ctan.org/pkg/snapshot? Or maybe http://ctan.org/pkg/arlatex? – cfr Jan 08 '14 at 00:19
  • @SándorKazi Yes, exactly – Yotam Jan 08 '14 at 12:02
  • @cfr bundledoc sounds right. I'm not certain what arlatex does. – Yotam Jan 08 '14 at 12:03
  • @Yotam I'm not sure either but I think it combines things into one file somehow. bundledoc seemed more likely given your description. I just mentioned the other as it came up as an alternative when I got the ctan link for bundledoc. – cfr Jan 08 '14 at 12:19
  • @cfr Cool!. What term did you search ? – Yotam Jan 08 '14 at 12:23
  • @Yotam I don't remember exactly. I just knew I'd seen something which could do this but couldn't remember quite what. I know I tried things like 'archive' and 'publish' but I might eventually have thought 'bundle' as it took me a few guesses to get useful results. – cfr Jan 08 '14 at 12:27

2 Answers2

8

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.

jon
  • 22,325
4

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.

cfr
  • 198,882