Is there an easy way to create a list of all external files (complete path) which are used by a LaTeX document (and its "sub-documents") by

  • \input
  • \include
  • \includegraphics ?

(may I have forgotten some input sources?)

  • You can parse the .log file (not very trivial, though). You can also use strace or similar tool (but this one counts as hardcore). Commented Jul 31, 2011 at 13:19
  • 1
    My dateiliste package includes a list of TeX files parsed in the document, but without complete path. (And not files used by includegraphics or similar.) Commented Jul 31, 2011 at 14:22

6 Answers 6


The snapshot package gives you a list of the external dependencies of a LaTeX document. Use it by saying


before the \documentclass command (to have the information written to a .dep file), or by saying


before the \documentclass command (to have the information written to the .log file).

  • 3
    Is there any way to use this information during the LaTeX build? I am trying to include all the distributed .tex files during a build using \usepackage{embedfile} and \embedfile{<...>.tex}...
    – fgysin
    Commented Feb 28, 2013 at 8:38

use the perl script mkjobtexmf available with every TeX distribution and run it like

mkjobtexmf --jobname <latex file> --cmd-tex pdflatex 

it creates an file <latex file>.fls which shows all used files, e.g. for a testfile named latex6:

PWD /home/voss/Documents
INPUT /usr/local/texlive/2011/texmf.cnf
INPUT /usr/local/texlive/2011/texmf/web2c/texmf.cnf
INPUT /usr/local/texlive/2011/texmf-var/web2c/pdftex/latex.fmt
INPUT latex6.tex
OUTPUT latex6.log
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/size10.clo
INPUT /usr/local/texlive/2011/texmf-dist/tex/latex/base/size10.clo
[ ... ]
  • 9
    Or you can simply run pdflatex -recorder <latex-file> to get the same effect. This is what mkjobtexmf does behind the scenes.
    – Lev Bishop
    Commented Jul 31, 2011 at 20:42
  • 1
    sure, what else should it do? However, you can create a texmf tree depending to the job which is more what -recorder can do.
    – user2478
    Commented Jul 31, 2011 at 21:00
  • 1
    the -recorder option is great !
    – Suresh
    Commented Jul 31, 2011 at 21:55
  • 3
    -recorder works better than mkjobtexmf when it comes to pgf plots. With -recorder you also get the input files used by pgf for the plots, whereas you dont with mkjobtexmf
    – masgo
    Commented Jun 26, 2015 at 12:01
  • 1
    Both ways work for me, but I end up with what seems like every line duplicated, so I used this technique with awk. It helped a lot, but I still have things like "filename" and "./filename". I'm trying to make a list of files to bundle up to send to a publisher (who won't download TeXlive?), and I'd like to reduce the list as much as possible.
    – Liam
    Commented Oct 23, 2018 at 18:23

This is a modified version of the @Gonzales answer with an additional python code to copy the figures to a new folder.

After using snapshot package to generate the .dep file:


use the following python code (say copy_figs.py) to copy the figures to a separate folder (for example, figs_used):

"""Copy figures used by document."""
import os
import shutil

DEP_FILE = 'main.dep'
TARGET_DIR = 'other_img/'
EXTENSIONS = ['pdf', 'pdf_tex', 'png']

def copy_image_files():
    with open(DEP_FILE, 'r') as f:
        for line in f:
            if '*{file}' not in line:
            value = line.split('{')[2].split('}')
            source = value[0]
            _, e = os.path.splitext(source)
            e = e.lower()[1:]
            if e not in EXTENSIONS:
            shutil.copy(source, TARGET_DIR)

if __name__ == '__main__':

To run the python code:

c:\Python27\python.exe copy_figs.py

in the folder where the Latex file is placed. It is assumed the original figures are in figs subfolder, and those figures used in the Latex file are copied to figs_used subfolder. The code copies .png and .pdf figure files.

  • Extremely useful piece of code. Easy to filter with if '*{file}' not in line:.
    – JeT
    Commented May 1, 2021 at 21:36
  • This is piece of gold. For inclusion of tables that are in other files, you could add or re.search(r'\.code\.tex',source) or source=="xkeyval.tex" to the last if statement of the function and texobviously to the extensions. Edited it also for my other needs, full code can be accessed here gist.github.com/samuelsaari/99f3ffe35a63482698571d713e9ee594 Commented Jul 1, 2022 at 11:03

If you put \listfiles as the very first line of the master file, the name of every used file is dumped to standard output, including style and font definition files. This is plain old LaTeX.


latexmk does a good job with this:

latexmk -deps main.tex

It prints everything: other .tex files, .bib files, .sty files, graphics.


Here is a quick-and-dirty implementation of a different approach, that does not require modifications of the source code, nor even recompilation. It just parses the log file, and needs a Unix-like command-line. Just run the following command from a terminal:

~ egrep -o '\./[^>) ]*' document.log


  • it only detect relative files
  • it will not work with funny file names (spaces or > or parentheses)
  • It does not list the figures. Commented Jan 21, 2019 at 19:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .