arxiv-latex-cleaner
arxiv-latex-cleaner copied to clipboard
When checking whether an image is referenced, \graphicspath is not taken into account
In LaTeX there's a feature allowing to set the root of all images with \graphicspath, then all image includes will be relative to this root, not the main tex file's directory.
However, this tool does not know about \graphicspath and therefore thinks that none of the images are referenced and deletes them all.
Dear @isarandi
Indeed our tool does not take \graphicspath into account. I marked the issue as enhancement (please do not close it) in case someone could give it a go and propose a PR.
Best,
This could be achieved by using the snapshot package.
If this package is included in a tex file using \RequirePackage{snapshot}
before everything else, it generates a list of all files that are included in the document, at least as far as LaTeX internally tracks them somehow. I just tried to use \graphicspath
with it.
For every graphics file included using \includegraphics
, snapshot
keeps the path in the file list. This could even supersede all parts of arxiv-latex-cleaner analyzing which tex files might be included in the main document(s).
To implement it, arxiv-latex-cleaner could compile the main document once, but prepending the \RequirePackage
call to the document, e.g. using pdflatex -jobname main '\RequirePackage{snapshot} \input{main}'
. One might want to configure the TeX engine/command to use.
Note that you can also modify the TEXINPUTS from within a LaTeX document by setting \input@path
or \l_file_search_path_seq
. The texinputs, however, are not included in the file list. One should also be able to write them to an auxiliary file from within a TeX file.
EDIT: Note that snapshot
does not consider .bib
files, but only the .bbl
files.