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:
\documentclass{report}
\usepackage{etoolbox}
\usepackage{float}
\floatstyle{ruled}
\newfloat{algorithm}{tbp}{loa}
\providecommand{\algorithmname}{Algorithm}
\floatname{algorithm}{\protect\algorithmname}
\let \listofalgorithms\listoftables
\patchcmd{\listofalgorithms}{\listtablename}{\algorithmname}{}{}
\patchcmd{\listofalgorithms}{\listtablename}{\algorithmname}{}{}
\patchcmd{\listofalgorithms}{\listtablename}{\algorithmname}{}{}
\patchcmd{\listofalgorithms}{lot}{loa}{}{}
\begin{document}
\listofalgorithms
\begin{algorithm}
Step 1: Do something complicated \\
Step 2: Do something even more complicated \\
\caption{Complicated algorithm}
\label{algo:complicated}
\end{algorithm}
\end{document}
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.
\patchcmd
only does one string at a time, so that you need three invocations to take care of three\listtablename
s within\listofalgorithms
.