I'm trying to write a write a simple implementation of a list of notation (more as a technical exercise than for actual use). I've run into a rather strange issue with numberings. The following is my implementation of the two relevant commands. The \notation
command creates a custom macro which contains the "notation" and the current page number (this seems to work OK), and the \listofnotation
command prints all defined notation into a list. The problem is that, calling \notation{one}
defines the macro \notation@1
and \notation{two}
creates \notation@2
as expected. However, when I call \listofnotation
, the output is \notation@1 two 1
and not \notation@1 one 1\par\notation@2 two 1
as I expect. Changing the starting index of \loopingindex
to 0 makes it work as expected, but the output is
\notation@0 one 1\par\notation@1 two 1
. This is quite peculiar.
\documentclass[12pt]{article}
\makeatletter
\newcount\notationcount
\newcommand\notation[1]{%
\global\advance\notationcount by1%
\expandafter\protected@edef\csname notation@\the\notationcount%
\endcsname{\protect{#1}\hskip1em\thepage}%
\expandafter\string\csname notation@\the\notationcount\endcsname%
}
\newcommand\listofnotation{%
\newcount\loopingindex%
\loopingindex=1%
\expandafter\ifx\csname notation@\the\loopingindex\endcsname\relax\else
\section*{List}%
\noindent%
\loop\expandafter\ifx%
\csname notation@\the\loopingindex\endcsname\relax%
\else%
\expandafter\string\csname notation@\the\loopingindex\endcsname~%
\csname notation@\the\loopingindex\endcsname\par\noindent%
\advance\loopingindex by1%
\repeat%
\fi%
}
\makeatother
\begin{document}
\notation{one}
\notation{two}
\listofnotation
\end{document}
I notice that the implementation is similar to that in the second example of https://www.tug.org/tug2012/booklet/hendrickson/AmyTugProc.pdf
Disclaimer: I had a quick look for a duplicate, but I wasn't really sure what to search for.
Thanks.