I'm just finishing my first document (a book), and I have to create an index (\makeindex
, \printindex
, \index{WORD}
, …).
I am using TexMaker on Linux.
I was wondering if it's possible to define something like a "macro", to be able to avoid adding \index{WORD}
before each word to be indexed (my document will have very many words to be indexed… :-).
I mean, I'd like to be able to define a command which would allow me – clicking a keyboard short-cut, for example [Ctrl][F9]
– to insert \index{WORD}
just before the WORD the cursor is on…
Skimming through TexMaker docs, I couldn't find anything useful to that intent…
UPDATE
I am following the suggestions in the comments, but I can't yet fully understand how to solve my problem… Feel quite dumb right now… 🙁
So: I add the command \iindex
in my book heading, as Sigur suggested:
\newcommand\iindex[1]{#1\index{#1}}
So far so good. Now I would like to associate a keyboard shortcut to it.
As suggested (always by Sigur) I look for a macros menu, but I can't find it (I use Texmaker 4.0.3).
As suggested by Aradnix, I open the User menu, and find these sub-menus:
- User Tags
- User Commands
- Customize Completion
Both Tags, Commands can be customized, but I suppose:
– Commands are for external commands (not my case).
– Tags are more promising, but what do I write in tag's LaTeX content? I mean, how do I refer to the word under cursor, which I want to index?
– Customize completion lists items already defined (which include for example \index{•}
), and I can add new commands; but, I can't understand how to associate it with a shortcut… :-).
Any more literal suggestion for a LaTeX newbe…?
If anybody solves and answers, I will accept the answer, of course… 🙂
Best Answer
Having added the suggested
\newcommand
to the preamble, you can add a user tag withas 'LaTeX Content'. Using the default shortcut, e.g. Shift + F1 if the first tag was chosen, will insert
\iindex{•}
, or if a word was selected, it will replaceword
with\iindex{word}
.I don't know if it is possible to change these shortcuts, I didn't see anything in Options --> Configure Texmaker --> Shortcuts.