How can I define a document command \FilesRequire
that writes to the .log
(or to the output console) a list of all packages internally required by the declared document class and by the packages that have been loaded by the user in a document?
For example, with this document
\documentclass{book}
\usepackage{graphicx}
\usepackage{amsmath}
\FilesRequire
\begin{document}
test
\end{document}
The output will be something like
Document class book: doesn't require additional packages.
Package graphicx requires: keyval, graphics.
Package amsmath requires: amstext[1995/01/25], amsbsy[1995/01/20],
amsopn[1995/01/20].
The command should have an optional argument for a comma separated list of the packages which will be inquired:
\documentclass{book}
\usepackage{graphicx}
\usepackage{amsmath}
\FilesRequire[amsmath]
\begin{document}
test
\end{document}
will produce just the information for the document class and for amsmath
:
Document class book: doesn't require additional packages.
Package amsmath requires: amstext[1995/01/25], amsbsy[1995/01/20],
amsopn[1995/01/20].
Basically, the command must produce a list of the arguments for all \RequirePackage
commands found inside the .cls
and .sty
files used in a document.
I am not interested in external scripts.
\LoadClass
and\RequirePackage
(and\usepackage
, if the hooking is done after\documentclass
). But it is not completely straightforward to get everything right. Maybe if you described your goal it would be possible to find an alternate solution (within TeX).