1

Is there a way to get a list of all used graphics with full pathnames? The problem is that I have set the $TEXINPUTS variable pointing to a directory containing images (which I included just using the filename), but I have also images included from the current directory and from some directories above (via ../image.png).

I tried the snapshot package but this gives me only the filenames without the complete path.

1

Many TeX compilers (pdfTeX, luaTeX, XeTeX) have an option -recorder, which behaves independent of the output mode (DVI, PDF). It records the input and output files in the file name <jobname>.fls.

Example:

% test.tex
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{example-image-a}
\end{document}

Compilation: pdflatex -recorder test

Then test.fls contains the absolute path of the image (grep INPUT test.fls|sort|uniq|grep png):

INPUT /absolute-path-to/texmf-dist/tex/latex/mwe/example-image-a.png
| improve this answer | |
1

This will output at the end of the log file the list of included graphic files, with the full path unless the image file is called with a relative path.

\documentclass{article}
\usepackage{graphicx,grffile}
\usepackage{etoolbox,xparse}

\makeatletter
\patchcmd{\Gin@setfile}
  {\@addtofilelist{#3}}
  {\@addtofilelist{#3}\studentaddtoiglist{#3}}
  {}{\ddt}
\makeatother

\ExplSyntaxOn
\NewDocumentCommand{\studentaddtoiglist}{m}
 {
  \tl_set:Nx \l_student_ig_filename_tl { #1 }
  \tl_set_from_file:Nnn \l_student_ig_filename_tl { } { "|kpsewhich~\l_student_ig_filename_tl" }
  \tl_gput_right:Nx \g_student_ig_files_tl { \l_student_ig_filename_tl ^^J }
 }
\AtEndDocument{\typeout{\g_student_ig_files_tl}}
\tl_new:N \l_student_ig_filename_tl
\tl_new:N \g_student_ig_files_tl
\tl_gset:Nn \g_student_ig_files_tl { ***~Graphic~files~*** ^^J }
\ExplSyntaxOff

\begin{document}

\includegraphics{../curva}

\includegraphics{example-image}

\includegraphics{brave-gnu-world-logo}

\end{document}

I ran this with

TEXINPUTS=/usr/local/texlive/2016/texmf-dist/doc/generic/pgf/images/: pdflatex mwe

so the variable TEXINPUTS is set for the specific job; it would be the same if it is set in the environment; in that case, just pdflatex mwe would suffice.

Here's the relevant part of the log file

*** Graphic files ***
../curva.jpg
/usr/local/texlive/2016/texmf-dist/tex/latex/mwe/example-image.png 
/usr/local/texlive/2016/texmf-dist/doc/generic/pgf/images/brave-gnu-world-logo.jpg 

Note that the last file wouldn't be found without setting TEXINPUTS.

| improve this answer | |

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.