It's on my task list for a while now, and this post made me ask a follow up question which is, in my mind, a missing part when setting such a list.
As an example, think of the standard notation of an n-dim space; I would use the following code to typeset it: \mathbb{R}^n
. Then, in order to make things quicker, I would define a macro \newcommand*{\Rn}{\mathbb{R}^n}
. So far so good. Now, I want to have a list of symbols as well. In short, the question is: what is the best practice to generate a list of symbols for complicated symbols?
Let me consider the nomencl
package, but I think the question is valid when one is using other alternatives as well. Currently, I have a file where I define all the macros I am using in my document, similar to the one I gave as an example above. Then, in order to generate a list's entry I would add
\nomenclature{$\mathbb{R}^n$}{$n$-dimensonal real space}
where I use my macro \Rn
for the first time. Is this the right/best way to go? One big drawback here is that when I would like to change the notation in the future, I will have to do it in two different places. Is there a smarter way to go? Somehow unify the two tasks of generating a list's entry and a macro which will be used in order to typeset the symbol later?
Best Answer
As long as you're sure that the first occurrence of
\Rn
is not in a section title or other moving argument, then you can define\Rn
to emit the desired\nomenclature
command and redefine itself:You can of course automatize this in a general macro:
and then say
and similarly for other symbols.
Caution: this will break miserably if you say
\section{Definition of $\Rn$}
and this is the first appearance of\Rn
.If you plan using those symbols in section titles, the following modified definition should work: