Take the 2-minute tour ×
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.

I have a short question about indexing.

Is it possible that latex automatically creates an entry in the index, when I first use a notation fixed by \newcommand?

share|improve this question
3  
Your question is not very clear. Could you give an example? In general, introducing notation into your publications by \newcommand is a good idea especially because it allows to bind index or glossary entries to it. –  Stephan Lehmke Mar 23 '12 at 14:53
    
Dear S.Lehmke, that is exactly what i intended to do. –  user12882 Mar 23 '12 at 16:35

1 Answer 1

up vote 1 down vote accepted

You can create your own command (called \notation here) to do this.

\documentclass{article}
\usepackage{makeidx}
\usepackage{mathabx} %For the \rip symbol
\newcommand\notation[2]{\newcommand{#1}{#2}{\index{#2}}}
\makeindex
\begin{document}
\notation{\tomb}{$\rip$}
After shooing them, I buried the bodies in a \tomb.
\printindex
\end{document}

Note that this creates the index entry when the command is defined, rather than upon its first use.

share|improve this answer
    
Thank you, though I can not yet upvote;) –  user12882 Mar 23 '12 at 16:24
    
I'd use \newcommand instead of \def. –  egreg Mar 23 '12 at 16:51
    
Sadly, this does not work with amsbook. –  user12882 Mar 23 '12 at 16:56
    
@user12882: for amsbook simply delete (or comment out) the line \usepackage{makeidx}. –  Gonzalo Medina Mar 23 '12 at 17:22
    
No I tried this as well - no error message, but no index in pdf file as well;( –  user12882 Mar 23 '12 at 17:26

Your Answer

 
discard

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.