4

Are there any resources available that list the control sequences/commands available from each package on CTAN (or other TeX hosting sites)?

I understand they are shown in the documentation PDF's, but this is rather tedious to look through and generate a list.

As an aside, why is this not required when submitting a package? Seems like it would be very helpful to package writers if they knew what commands are defined and where.

12
  • 12
    there are thousands of packages on ctan, and some of them define thousands of commands, what would you do with such a list that you couldn't do with a google search of ctan? Aug 1 '17 at 15:50
  • 7
    For package writing, you should always use an internal namespace unique to your package or class for package internal commands (e.g. \mypkg@foo etc.) to avoid name clashes. For user facing commands, if you have a name that's the same as another package's name, the chances are that the packages shouldn't be used together anyway. So it's not clear what a list would do for you.
    – Alan Munn
    Aug 1 '17 at 15:54
  • 2
    @DavidCarlisle Heck, I don't even remember all the commands defined in my own packages! Aug 1 '17 at 16:54
  • 4
    The list might be useless in some sense that some commands are just overwritten by packages or changed or improved or screwed up...
    – user31729
    Aug 1 '17 at 17:06
  • 3
    @StevenB.Segletes: Pretty easy for your packages: \StackUp, \StackDown, \StackBelow, \StackBehind, \StackAfter, \StackBefore, \StackHere, and thousand variants :-P
    – user31729
    Aug 1 '17 at 18:21
5

I agree with the sceptical tenor of the comments above - I don't see how such a list would be useful in real life. However, just for the heck of it, here is a little bash script that attempts to list all commands in all locally installed *.sty files.

#!/bin/bash

# search file system for all latex package files
packages=$(sh -c "find / -name '*.sty' | grep -oE '/([^/]+)/[^/]+\.sty$' | cut -f2 -d'/' | sort | uniq" 2>/dev/null)

# iterate over all packages to list their macros.
for package in $packages; do
    # run Martin Scharrer's `latexdef` on each package name to list the
    # commands defined therein. The loop hangs on arsclassica, so we 
    # skip it.
    if [ $package != "arsclassica" ]; then
        echo "package: $package"
        latexdef -l -p $package
    fi
done

Note that latexdef invokes TeX on each package, and sometimes that doesn't work properly, and you get compile error messages. You also get some empty lines, so you would have to filter the output. Also, it seems the compiler hangs when latexdef tries to process package arsclassica, which I therefore manually excluded. Since I only ever let the script run to package names starting with letter c, it is quite possible that more hangups would occur, and more exemptions be required, further on.

Also note that this does not cover *.cls or other files that may contain command definitions.

6
  • +1 for the -l option of texdef alone. And if you want internal macros too, you can use -ll.
    – Alan Munn
    Aug 1 '17 at 21:16
  • @AlanMunn Do you actually have latexdef? If so, where from? texdef -t latex is what I usually use, but the help promises latexdef. I just don't have it.
    – cfr
    Aug 2 '17 at 1:36
  • 1
    @cfr Just make latexdef a symbolic link to texdef.pl in /usr/local/bin/.
    – Alan Munn
    Aug 2 '17 at 2:27
  • @AlanMunn Why /usr/local/bin/? For persistence?
    – cfr
    Aug 2 '17 at 2:29
  • @cfr Probably. I don't really remember. Mine has been on my system there since 2013. I may have installed it manually at some point, since checking the link it resolves to a version in /usr/local/bin. I've never understood why the link isn't automatically included in TL.
    – Alan Munn
    Aug 2 '17 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.