No, it is not possible. Packages may define commands in several ways, besides the standard \def
(and variants) or \newcommand
and \DeclareRobustCommand
. Consider for instance, \DeclareMathSymbol
or \DeclareTextCommand
(but there are other ways even in the LaTeX kernel).
Just to make a few examples, algpseudocode
uses \algdef
and \algnewcommand
; other package have their own methods. They can even define commands dynamically based on user input. Other commands may have “limited life” (think to the unit names for siunitx
) and different syntax depending on where they're called.
The list should also exclude all internal commands and others such as \temp
\next
or \do
that are used as scratch macro names.
As regards to syntax, consider that, for instance, memoir
redefines \chapter
and the other sectional commands to have two optional arguments, rather than one. Other packages might define *
-variants of existing commands, and in order to discover this you need to analyze the definition itself: basically, if \foo
is defined and a package wants to add a *
-variant, we would find something like
\let\org@foo\foo
\renewcommand{\foo}{\@ifstar\foo@star\org@foo}
\newcommand{\foo@star}{...<whatever>...}
The number of packages and commands they define is huge. Really. Doing a lexical analysis of just the packages loaded by the user would mean following all \RequirePackage
in called ones. And maybe some of them are only loaded conditionally. Not to mention that commands might be defined in other files input by packages, so you should follow also \input
and similar commands.
Good luck. ;-)
algpseudocode
uses\algdef
or\algnewcommand
for defining its commands. – egreg Dec 15 '15 at 21:11