2

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?

  • 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

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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