TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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:

  \nomenclature{$\mathbb{R}^n$}{$n$-dimensional real space}%

You can of course automatize this in a general macro:


and then say

\definesymbol{\Rn}{\mathbb{R}^n}{$n$-dimensional real space}

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:

share|improve this answer
Regarding caution: Will using optional argument for section like \section[Definition of $\Rn$]{definition of $\mathbb{R}^n$} over come this failure? – Harish Kumar May 14 '12 at 9:24
@HarishKumar Yes; definitely. The first appearance of \Rn the next time the document is compiled would be in the table of contents! Putting \mathbb{R}^n in the optional argument and \Rn in the mandatory one might solve the issue. – egreg May 14 '12 at 9:27
Trying to make sure I understand, if the first time \Rn appears is in a section's title, then it should be produced by \section[Definition of $\mathbb{R}^n$]{Definition of $\Rn$}? – Dror May 14 '12 at 9:38
@egreg: Sorry. I typed reverse. So \section[Definition of $\mathbb{R}^n$]{definition of $\Rn$} (This is what I meant) solves it. I wonder whether there is any other fix for this problem besides optional argument? It will be nice of you if you incorporate all these remedies in to your answer. (already upvoted +1). – Harish Kumar May 14 '12 at 9:59
@Dror Yes. If I find time I'll think to a better way. Today is lecture day, starting at 11:30 and ending at 18:30; but the last two hours are the LaTeX course. :-) – egreg May 14 '12 at 12:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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