LetLtxMacro 未如預期運作

LetLtxMacro 未如預期運作

如果註解掉的行替換了上面的行,則不會設定索引。為什麼不?

\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

相關內容