
如果註解掉的行替換了上面的行,則不會設定索引。為什麼不?
\documentclass{article}
\usepackage{imakeidx}
\usepackage{hyperref}
\usepackage{letltxmacro}
\def\fn#1#2{%
\hyperpage{#2} n.\,#1%
}%
\LetLtxMacro{\oldindex}{\index}
\newcommand{\is}[1]{%
\if@noftnote%
\index{#1}%
%\oldindex{#1}%
\else%
\index{#1|fn{\number\value{footnote}}}%
%\oldindex{#1|fn{\number\value{footnote}}}%
\fi%
}
\makeindex
\begin{document}
Cheese.\footnote{\is{cake}cake.}
\printindex
\end{document}
答案1
\LetLtxMacro
做按預期工作。\oldindex
有以下含義\index
在分配任務時,特別是這個被放置前 \makeindex
,其中 LaTeX\index
僅作為虛擬對象,沒有任何操作。\makeindex
重新定義\index
將條目寫入.idx
檔案。
更正:
\makeindex % redefines \index
\LetLtxMacro\oldindex\index