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


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...


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.

  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Jun 12, 2014 at 9:49
  • 3
    after your definition you should be able to use \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. Jun 12, 2014 at 12:27

1 Answer 1


As you haven't given a MWE it is not clear to me what is not working as this looks fine to me.

Here is something that I have used in the past. In TeX the double quote character is not very useful (as ``life'' is better than "life" in TeX), so when I need an index I redefine the double quotes so that "something" puts something in \textsf and also adds it to the index.


\catcode`\"=13  % make the double quote character " active
\gdef"#1"{\textsf{#1}\index{#1}} % define "*" to do indexing+\textsf


Here is "something" that I am "indexing".


enter image description here enter image description here

Rather than my fancy quote command what you have should work, so perhaps your problems lie elsewhere?

To produce the index you need:

  • \usepackage{makeidx} and \makeindex in the preamble

  • a \printindex where you want the index to appear, and,

  • you need to run makeindex on the idx file that LaTeX produces.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .