While working with some of my co-workers it happens that we have different versions of TeXLive. Because of that, some of them cannot compile my documents due to package missing.

A question came to my mind: What if it is possible to detect all packages and versions that are used for a specific document; see if that package/version is installed in the system; and if not download it and install it in a specific folder?

For compilation I always use a Makefile made by myself and I add there a sty and bst files if they are required for that document. But I do this manually. Thus I have this variable:


I know from this question Checking I have LaTeX packages installed and Generate list of all installed (La)TeX files that is possible to determine the full list of installed packages.

Moreover, I know that with the conjunction of \RequirePackage{snapshot} and bundledoc it is possible to generate the list of all packages that were used for compilation and copy them to my sty folder.

This is included in main file before \documentclass:

% List the files used in compilation
% It generates a 'job.dep' file that can be post-processed by 'bundledoc'
% Required for package-gen.sh

And the bash script package-gen.sh:

# package-gen.sh -- Generates the list of packages required for compilation

# Dependency file

# Styles folder

# List of files to copy (sty, def, cls)
#LIST=`bundledoc --listdeps=only $MAIN.dep | egrep -iw 'sty|def|cls'`
LIST=`bundledoc --listdeps=only $MAIN.dep | egrep -iw 'texlive/2015'`

# Create styles folder if it doesn't exist
if [ ! -d "$STYDIR" ]; then
    mkdir $STYDIR

# Copy files to temporary folder
for file in $LIST; do
    cp -rf $file $STYDIR

So the question is: does anyone know how can I do this automatically... downloading the packages from CTAN that are not installed in the system and copy them to sty folder? It would be desirable to do it on fly, i.e., right after compilation starts.

  • 1
    MikTeX does this. But it's windows only. – Mark Oct 6 '15 at 18:24
  • Yes. But I am searching for something for Linux. – cacamailg Oct 6 '15 at 19:03
  • I'd be wary of downloading random executable content from the Internet... – vonbrand Oct 6 '15 at 20:01
  • 1
    Well, it is not random. It is specific packages from CTAN. Only the ones that are not locally installed. – cacamailg Oct 6 '15 at 20:20

Your Answer

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

Browse other questions tagged or ask your own question.