I want to give all the needed packages that don't come with a basic LaTeX installation zipped with the source code of a book. But those packages should be in a subdirectory of the directory where the source code is. If someone downloads the .zip how can LaTeX use those packages that are neither in the installation directories of LaTeX nor in the same directory as the source code? The goal is to have only the source code in its directory and the packages in a subdirectory. I think the preamble should be something like this:


But the import package only seems to work with .tex files.


If TEXINPUTS includes a path component of .// then all directories below the current one will be searched.

So (depending on your operating system) you can do

TEXINPUTS=.//: pdflatex myfile

or set TEXINPUTS with setenv or export or set or whatever is needed. Or for a cross platform solution TEXINPUTS can be set in the texmf.cnf configuration file rather than as an environment variable.

  • I think this is could be a good solution, I just have to say so in a readme, but if I could make a Makefile to do that it would be even better. Any idea of how would it be? – Arturo Feb 14 '15 at 20:51
  • @Arturo in a Makefile you just put a tab in front of the line in my answer – David Carlisle Feb 14 '15 at 20:54
  • @Arturo or perhaps stackoverflow.com/questions/23843106/… – David Carlisle Feb 14 '15 at 21:25

This is taken from the UK TeX FAQ entry All the files used by this document:

The snapshot package helps the owner of a LaTeX document obtain a list of the external dependencies of the document, in a form that can be embedded at the top of the document. The intended use of the package is the creation of archival copies of documents, but it has application in document exchange situations too.

The bundledoc system uses snapshot to produce an archive (e.g., .tar.gz or .zip) of the files needed by your document; it comes with configuration files for use with TeX Live-Unix and MiKTeX. It's plainly useful when you're sending the first copy of a document.

mkjobtexmf finds which files are used in a 'job', either via the -recorder option of TeX, or by using the (Unix) command strace to keep an eye on what TeX is doing. The files thus found are copied (or linked) to a directory which may then be saved for transmission or archiving.

You might be interested in bundledoc.

  • To compile the source the packages should be extracted first in the same directory as the book. I don't want the .sty files to finish in the same directory. – Arturo Feb 14 '15 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.