# Can emphasize produce an index item?

I would like to have a command which empasizes a term (like a definition in a mathematical text) and produces an item for the index (I use makeindex). Ideally the macro should not be too invasive, such that the index can be turned off it this might be desired.

Can you provide me a solution for this task?

-
@Martin: I think that it would be more semantic to name the macro something like \keyword for example because what you want to do is to focus one special word. –  projetmbc Apr 4 '12 at 19:11

Here is an example: using the macro \myemph{} causes the word to be added to the index and the regular \emph{} macro is still available and does not add the term to the index.

\documentclass{memoir}
\makeindex
\newcommand{\myemph}[1]{\index{#1}\emph{#1}}%

\begin{document}
This is in index: \myemph{foo}

This is not in index: \emph{bar}

\backmatter
\printindex
\end{document}

-

Or also this, if you prefer:

\let\oldemph\emph
\renewcommand{\emph}[1]{\index{#1}\oldemph{#1}}


Now you can use \emph as you wished.

If you want a starred version, this might help (you need the suffix package):

\documentclass{article}
\usepackage{suffix}

\makeindex

\let\oldemph\emph    % save old \emph
\renewcommand\emph[1]{\oldemph{#1}}    % "new" \emph without star
\WithSuffix\newcommand\emph*[1]{\oldemph{#1}\index{#1}}    % new \emph with a star

\begin{document}
\emph{test} \\   % doesn't get indexed
\emph*{test2}   % gets indexed
\end{document}

-
But the OP specifically requested that he want to be able to turn this feature off, so perhaps defining \emph* which added to the index would be an option, and the regular \emph would not add it to the index. –  Peter Grill Apr 4 '12 at 19:22