[texhax] Locating macros

Uwe Lück uwe.lueck at web.de
Thu Jul 10 14:51:50 CEST 2008

At 16:55 07.07.08, Yo Sato wrote:
>Hi all,
>I was wondering what's the best way to locate the source of a
>macro/command (ie which file the definition resides in).
>The only way I know at the moment is simply go through the loaded
>style files, first the personal and then the default /texmf
>directories, which can become a big hassle. Also, this method would
>fail to uniquely identify the definition that is actually used, if
>there are multiple occurrences of the same-named macro across
>different files...
>So I feel there must be a better way. I use \show to show the
>'content' of a macro, but it doesn't tell you where it comes from...

I have had the same problem these days, with own packages
I made in the previous millenium.

What just came to my mind:

1. use \listfiles in your document `job.tex' (say)
2. convert the list of files in job.log as follows:
     turn a line containing package `foo' into
3. change job.tex as follows:
     right after \documentclass, insert
         and then the \afterpackage list as above.
4. after the next run of job.tex, look in job.log
where the result of \show\foo changes.

[sorry, not tested]

This confines the search to packages that you are
actually using. For the "conversion", you may have
a smart editor or be able to use Perl or AWK
(I am developping docstrip-like macros for purposes
like this one, some already working).

Difficulties coming to my mind:
* what about .def files? and some of these have been
loaded by initex already.
* If you use memoir.cls, the definition may be there.

HTH -- Uwe.

More information about the texhax mailing list