once I asked in Insert key words & key phrases into toc whether it is possible to insert some keywords in the toc that it looks like this:
Contents
1 section .............................1
key word 1 - key phrase 2 - key word 3
1.1 subsection ...............................5
key word 1 - key phrase 2 - key word 3 -
key word 4 - key phrase 5 - key word 6
egreg provided this answer which works perfectly well:
\documentclass[a4paper]{article}
\usepackage{etoolbox}
\makeatletter
\newif\ifsection
\newif\ifsubsection
\newtoks\keywordstoks
\preto\section{\flushkeywords\sectiontrue\subsectionfalse}
\preto\subsection{\flushkeywords\sectionfalse\subsectiontrue}
\preto\enddocument{\flushkeywords}
\newcommand{\flushkeywords}{%
\ifsection\addtocontents{toc}{\formatkwsection{\protect\@gobble\the\keywordstoks\relax}}\fi
\ifsubsection\addtocontents{toc}{\formatkwsubsection{\protect\@gobble\the\keywordstoks\relax}}\fi
\keywordstoks={}}
\newcommand{\keyword}[1]{\@bsphack\keywordstoks=\expandafter{\the\keywordstoks\kwsep#1} \@esphack}
\newrobustcmd{\kwsep}{~-- }
\newrobustcmd{\formatkwsection}[1]{#1\par\medskip}
\newrobustcmd{\formatkwsubsection}[1]{{\leftskip=2.2em\relax#1\par}\smallskip}
\makeatother
\begin{document}
\tableofcontents
\section{Section}
Abc \keyword{key1} def \keyword{key2}
\subsection{Subsection}
Ciao \keyword{key3} ciao \keyword{key4}
\subsection{Another}
x
\end{document}
Now my question: Is it possible to hyperref-ize the keywords?