平均能量损失

平均能量损失

使用 MakeIndex(通过memoir类),我想通过引用来索引页面注释页码(在出现注释的注释部分)以及音符编号. 尝试\thepagenote在某处包含对文档中最后一页注释的编号的引用。

例如,下面给出的 MWE 有 4 页注释,尝试索引第一页注释最终在索引中引用了最后一页(第四页)的注释

我注意到,在完成所有处理后,.ind文件仍然保留\thepagenote页码,例如

\item First pagenote, \ipn{\thepagenote}{5}.

所以我想我必须想办法扩大\thepagenote这个答案似乎密切相关,但直接移植该解决方案似乎并没有产生预期的结果——数字\thepagenote被硬编码到.ind文件中,但它仍然是最后一页的注释。

在此处输入图片描述

平均能量损失

\documentclass{memoir}
\usepackage{lipsum}

\newcommand{\ipn}[2]{PAGE #2 NOTE #1}

\makeindex
\makepagenote

\begin{document}
\mainmatter
\part{Part}
\chapter{Chapter}
\index{1st index term}%
\lipsum[1]\pagenote{First pagenote\index{2nd index term|ipn{\thepagenote}}}
\lipsum[2]\pagenote{Second pagenote}
\lipsum[3]\pagenote{Third pagenote}
\lipsum[4]\pagenote{Fourth pagenote}
\backmatter
\printpagenotes
\printindex
\end{document}

MWE 类似参考答案

https://tex.stackexchange.com/a/282610/47128

\documentclass{memoir}

\usepackage{lipsum}
\usepackage{hyperref}

\newcommand\pn[2]{\hyperpage{#2}n#1}

\makeatletter
\let\if@nopgnote\iffalse % just for the example
\newcommand{\is}[1]{%
  \if@nopgnote
    \index{#1}%
  \else
    \edef\tempnumber{\thepagenote}%
    \expandafter\pagenoteindex\expandafter{\tempnumber}{#1}%
  \fi
}
\makeatother
\newcommand{\pagenoteindex}[2]{\index{#2|pn{#1}}}

\makeindex
\makepagenote

\begin{document}
\mainmatter
\part{part}
\chapter{chapter}
\lipsum[1]\pagenote{First pagenote}
\lipsum[2]\pagenote{Second pagenote.\is{inside second pagenote}}
\lipsum[3]\pagenote{Third pagenote.}
\backmatter
\printpagenotes
\printindex
\end{document}

答案1

我有点盲目地结合了我之前引用的答案:

结果如下。对 memoir 命令的更改\m@m@wrpnote可能可以用 来缩减,\xpatchcmd但我对此并不熟悉。对原始命令的添加用 来标记BEGIN ADDITIONS

\documentclass{memoir}

\usepackage{lipsum}
\usepackage{hyperref}

\newcommand\pn[2]{\hyperpage{#2}n#1}

\makeatletter
\let\if@noftnote\iffalse % just for the example
\newcommand{\is}[1]{%
  \edef\tempnumber{\thepnotemirror}%
  \expandafter\pagenoteindex\expandafter{\tempnumber}{#1}%
}
\makeatother
\newcommand{\pagenoteindex}[2]{\index{#2|pn{#1}}}


\newcounter{pnotemirror}
\makeatletter
\renewcommand{\m@m@wrpnote}[2][]{%
  \mem@pn@lastkern=\lastkern%
  \refstepcounter{pagenoteshadow}%
  \ifm@mpnpageopt%
    \phantomsection%
    \label{pagenote\thepagenoteshadow-\thesheetsequence}%
  \fi%
  \if\mem@pn@step%
    \@ifmtarg{#1}{% BEGIN ADDITION
      \ifnumequal{\value{pagenote}}{0}%
      {\m@m@pnwrite\@notefile{}{\string\setcounter{pnotemirror}{0}}}%
      {}% END ADDITION
      \refstepcounter{pagenote}%
      % this enables the ^{1,2} feature
      \ifdim\mem@pn@lastkern=\multiplefootnotemarker%
        \m@mmf@prepare% rerun
      \fi%
      \mem@pn@multiple@marker{\notenumintext{\thepagenote}}%
    }{\m@mmf@prepare}%
  \fi%
  \ifm@mpn@new@chap%
    \global\m@mpn@new@chapfalse%
    \addtonotes{\string\pagenotesubhead{\@chapapp}{\thechapter}{\pnchap}}%
  \fi%
  \ifm@mpn@new@schap%
    \global\m@mpn@new@schapfalse%
    \addtonotes{\string\pagenotesubheadstarred{\@chapapp}{}{\pnschap}}%
  \fi%
  \m@m@pnwrite\@notefile{}%
    {% BEGIN ADDITION
      \string\refstepcounter{pnotemirror}% END ADDITION
      \string\startnoteentry{\thepagenote}}%
  \m@m@pnwrited\@notefile{}{{#1}}%
  \m@m@pnwrite\@notefile{}%
    {{pagenote\thepagenoteshadow-\thesheetsequence}}%
  \m@m@pnwrite@fourtharg{#1}%
  \begingroup%
    \newlinechar='40%
    \m@m@pnwrited\@notefile{}{#2}%
  \endgroup%
  \m@m@pnwrite\@notefile{}%
  {\string\endnoteentry}%
  \endgroup%
  \@esphack}
\makeatother

\makeindex
\makepagenote

\begin{document}
\mainmatter
\part{Part}
\chapter{Chapter}
\index{Some index term}%
\lipsum[1]\pagenote{Ch. 1, First pagenote}
\lipsum[2]\pagenote{Ch. 1, Second pagenote\is{Ch. 1, Second pagenote}}
\lipsum[3]\pagenote{Ch. 1, Third pagenote}
\lipsum[4]\pagenote{Ch. 1, Fourth pagenote}
\chapter{Chapter}
\lipsum[5]\pagenote{Ch. 2, First pagenote}
\lipsum[6]\pagenote{Ch. 2, Second pagenote}
\lipsum[7]\pagenote{Ch. 2, Third pagenote\is{Ch. 2, Third pagenote}}
\backmatter
\printpagenotes
\printindex
\end{document}

相关内容