# List all macro calls

Assume I have a big document that uses several macros, say \AAA, \BBB, etc., through the whole document.

Is there a way that I can have a list of all these macros in the final pdf? I want to repeat all the \AAA calls at the beginning for example, to have a very quick glance at them while writing the document.

An optional feature would use hyperref to click on one \AAA of the list to go directly on the pdf page where the macro is actually used.

• \tracingmacros? – Henri Menke Mar 15 '14 at 9:42
• This seems overkill. I only want some macros, not all. – wwjoze Mar 15 '14 at 9:48

You could put a \hypertarget in every call of \AAA, where the name uses a counter. Afterwards you can reference it by \hyperlink.

In the example the \AAA No. 1, etc. are clickable links.

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{pgffor,hyperref}
\newcount\countAAA
\countAAA=0
\newcommand*\AAA{%
\hypertarget{AAA\the\countAAA}{}%
AAA% your replacement text goes here
}
\newcommand\blindtext{\par\noindent Lorem ipsum dolor sit amet \par\noindent}
\begin{document}
\section{Some text with \texttt{\string\AAA} macros}
\blindtext
\AAA
\blindtext
\AAA
\blindtext
\AAA
\blindtext
\AAA
\section{List of \texttt{\string\AAA} calls}
There are \the\countAAA\ calls of \texttt{\string\AAA} throughout the document.

\foreach \i in {1,...,\the\countAAA} {

• @wwjoze You can also replace the pgffor package with tikz, if you need drawing functionality. – Henri Menke Mar 15 '14 at 12:59