I would like to define a command which creates an index with a certain name, when i pass the name, and doesn't create any index if there is no name passed.
My first idea was to write it like that:
\newcommand{\kw}[1][]{\emph{#2}\index{#1}}
but the compiler gets stuch when I pass an empty optional argument. How can I build an if-then structure like the following?
\newcommand{\kw}[1][]{
if(#1 is not empty)
\emph{#2}\index{#1}}
else
\emph{#2}
}