I'm working on a Python script that will try to find the packages really used in a (La)TeX file or a piece of a (La)TeX file. I can't just keep the packages indicated via
\usepackage because if I am interesting in a part of a (La)TeX file, only some packages will be used.
I am not looking for an exact solution. In other words, my script will try to do the best, and trying to do the best will be good enough as Radiohead could say in an Optimistic day.
If there is only one part of packages founded, typically if a new LaTeX file is built with only the packages found by my script and the compilation failed, then my script will try brutally to add the packages unkept that are imported via
\usepackage in the original file. I will try do clever things later but not right now.
In a (La)TeX file or a piece of a (La)TeX file, I look for macros used and then I search in a kind of BDD, maybe a NoSQL one, build by my script.
So I need to associate a name of macro to packages, one name can be associated to several packages.
For the moment, I am not concerned with user's packages (that will be done later).
What am I looking for ?
- Can I know the packages really used by a LaTeX compiler ? It seems that in the log file all packages imported by the LaTeX file are used by the compiler. That looks normal but if the compiler can know which packages are really used, I will happy to use that (because my script will have no reason to birth).
- Where can I find the source codes where the macros are defined in packages available in the TeX Live Utility ?
PS: I know the use of
\csname that complexifies the search but for the moment I will try to work without this hoping that searching for hard coding names of macros will be enough.