I am struggling with creating a macro that would enable me to create index items by macro. From a former post (LaTeX: is it possible to create a macro to add words to index (using TexMaker)?) I have tried to use the following, but I can't get it to work. I am using TexmMakerX on Mac (home) and Windows (work).
I have added
\newcommand\iindex[1]{#1\index{#1}}
to my preamble. I also added the same line to User -> User Macros, but the macro would only print \newcommand\iindex[1]{#1\index{#1}}
on the screen. Also \iindex
would not work. I can't figure out how to use this macro... Ideally I'd like it to highlight a word and insert \index{WORD}
right before that word.
I am obviously not a LaTeX pro... and I would really appreciate a hint...
Edit/Comment:
Thanks alls for your kind answers - sorry for forgetting the MWE. Indexing is working fine generally. All commands in my preamble are working without problems.
I have a large document without index, and I want to add an index to it. Since it is really tedious to copy each word that I want to index, then type \index{PASTE} and continue I am looking for a semi-automatic method.
In AucTeX on Emacs you could position the cursor within a word and hit a key to index it, but I don't use either one any more. I was trying to achieve sopmething liek this in TexMakerX by combining the \newcommand
from the first post above with a TexMakerX makro.
I like the Andrew's suggestion below, but would prefer highlighting a word and indexing it with a keystroke...
Thanks to all, it would be cool if you had an idea to help me.
\documentclass{...}
and ending with\end{document}
.\iindex{WORD}
to typeset WORD and add it to the index. However your question appears not to be about latex at all but about how to highlight WORD and have it replaced by\iindex{WORD}
. That is purely a function of the editor you are using it is unrelated to the LaTeX system itself, but you have not even said which editor that is.