我曾经问过将关键词和关键短语插入目录中是否可以在目录中插入一些关键字,如下所示:
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 提供了这个非常有效的答案:
\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}
现在我的问题是:是否可以对关键词进行超级引用?
答案1
\keyword
将的定义改为
\newcommand{\keyword}[1]{\@bsphack
\keywordstoks=\expandafter{%
\the\keywordstoks\kwsep\protect\hyperlink{keyword.#1}{#1}}%
\hypertarget{keyword.#1}{}%
\@esphack}