So I've started to become more familiar with LaTeX, still a beginner but comfortable enough to try out the scary patchcmd from the etoolbox package. What has me mystified though is how people find out what the definition of the original macros, especially native latex macros, look like so they can patch it.

For example, I've been shown that one can modify the built in \listoftables in a fashion similar to this:




\let \listofalgorithms\listoftables

  Step 1: Do something complicated \\
  Step 2: Do something even more complicated \\
\caption{Complicated algorithm}

Through some experimentation I've found out that the first patchcmd-line seems to be changing the title of the list, but I've no idea what the other two does as I don't know the original definition of \listoftables.

Apart from the mandatory google search I have checked:

  • the files in my MikTeX distribution for the string listoftables but didn't manage to find anything that seemed to define the macro.

  • the LateX2e documentation but only found references no definition

  • read a few answers here on the site, such as Werner's and yo's

I've foud out that there is a package called texdef which can be used (in terminal), but for some reason the following commands:

latexdef -c report listoftables -s
latexdef -c report section -s

both yield undefined as an answer.


As usual, the last attempt at finding an answer before posting the question leads an answer.

There are a few commands one can use in a latex document to show the source of a macro:

  • \show\listoftables will print the definition of listoftables to the log
  • \meaning\listoftables will print it in the document
  • More can be found in this answer by Leo Liu

To get texdef to work I had to specify the TeX format with the flag -t, and in doing so I also had to install the currfile package in MikTeX. I removed the -s (for viewing original source code) as this was unnecessary for my purposes.

latexdef -t latex -c report -f listoftables

The documentation for texdef can be found here. I also found the definitions of a lot of latex macros in the latex base particularly in the classes documentation.


Typing texdoc source2e will give you over 600 pages containing all the basic LaTeX code definitions. For the macro definitions used within packages and other classes texdoc class/package will often show the code for them, depending on the documentation provided by the authors.

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