
7 n.\,1
ありますか?(ページに複数のメモがある場合にインデックス形式にしたいので、これが必要です7\,n
。
PS. リクエストに応じて、より明確に述べます。現在のページの脚注の数を返すマクロを定義できますか\fnnonthispage
? より明確に言う方法がわかりません。
PS II. マクロの使用方法は次のとおりです。最初のページには 2 つの注釈があるため、エントリで番号を指定する必要があります。ただし、2 ページ目には注釈が 1 つしかないため、番号を指定しないでください。ページに部分的な脚注が含まれている場合は、それも 1 つとしてカウントする必要があります。
%compile with: pdflatex file; makeindex file; pdflatex file
\documentclass{article}
\usepackage{imakeidx}
\usepackage{hyperref}
\usepackage{letltxmacro}
\makeindex
% \see{} inserts a see in the next entry, after the pp.
\def\seeentry{}
% must be global to work within footnote
\def\see#1{\gdef\seeentry{#1}}
\def\seesep{;\space}
\def\seetext{see\space}
% \index{<entry>|fn} marks the ref. as to a note
\def\fn#1#2{% insert see if \seeentry is not empty
\hyperpage{#2} n.\,#1\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
% ----- here is how the desired macro could be used:
%\hyperpage{#2}%
%\ifnum\fnnonthispage>1
%\space n.\,#1\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
%\else
%\,n.\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
%\fi
}%
% Redefining \index to mark reff. to notes as such.
\LetLtxMacro{\oldindex}{\index}
\renewcommand{\index}[1]{%
\if@noftnote%
\oldindex{#1}%
\else%
\oldindex{#1|fn{\number\value{footnote}}}
\fi%
}
\begin{document}
Cheese.\footnote{\index{cake}cake.}
Whether it be cheese or not.\footnote{What?}
\newpage
Oranges are called Chinese apples in German.\footnote{And in
Danish, of course.\index{Danish}}
\printindex
\end{document}
答え1
解決策は次のとおりです。マクロが定義されていない場合は、出力ページごとに複数の脚注があるかどうかを確認します\mtfnexiste<pagenumber>
。
注記上記の John Kormylo 氏のコメントは重要ですが、私はここでその点に注意を払っていませんでした。お知らせください。
\documentclass{article}
\usepackage{imakeidx}
\usepackage{hyperref}
\usepackage{letltxmacro}
\makeindex
% \see{} inserts a see in the next entry, after the pp.
\def\seeentry{}
% must be global to work within footnote
\def\see#1{\gdef\seeentry{#1}}
\def\seesep{;\space}
\def\seetext{see\space}
% \index{<entry>|fn} marks the ref. as to a note
\newcounter{mtfn}
\setcounter{mtfn}{1}
\makeatletter
\patchcmd\@outputpage{\stepcounter{page}}{%
\ifnum\value{mtfn}<\value{footnote}
\expandafter\gdef\csname mtfnexiste\thepage\endcsname{x}\fi
\setcounter{mtfn}{\value{footnote}}\stepcounter{mtfn}%
\stepcounter{page}}{}{\errmessage{no}}
\def\fn#1#2{% insert see if \seeentry is not empty
\hyperpage{#2}%
\expandafter\ifx\csname mtfnexiste\@secondoftwo#2\endcsname\relax
\,n.\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
\else
\space n.\,#1\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
\fi
}%
\makeatother
% Redefining \index to mark reff. to notes as such.
\LetLtxMacro{\oldindex}{\index}
\renewcommand{\index}[1]{%
\if@noftnote%
\oldindex{#1}%
\else%
\oldindex{#1|fn{\number\value{footnote}}}
\fi%
}
\begin{document}
Cheese.\footnote{\index{cake}cake.}
Whether it be cheese or not.\footnote{What?}
\newpage
Oranges are called Chinese apples in German.\footnote{And in
Danish, of course.\index{Danish}}
\printindex
\end{document}
アップデート長い脚注の例では、最初のページの 2 番目の脚注ですが、索引付けされた単語は 2 ページ目にあり、脚注は 1 つしかないため、問題が発生します。
\documentclass{article}
\usepackage{imakeidx}
\usepackage{hyperref}
\usepackage{letltxmacro}
\usepackage{lipsum}
\makeindex
% \see{} inserts a see in the next entry, after the pp.
\def\seeentry{}
% must be global to work within footnote
\def\see#1{\gdef\seeentry{#1}}
\def\seesep{;\space}
\def\seetext{see\space}
% \index{<entry>|fn} marks the ref. as to a note
\newcounter{mtfn}
\setcounter{mtfn}{1}
\makeatletter
\patchcmd\@outputpage{\stepcounter{page}}{%
\ifnum\value{mtfn}<\value{footnote}
\expandafter\gdef\csname mtfnexiste\thepage\endcsname{x}\fi
\setcounter{mtfn}{\value{footnote}}\stepcounter{mtfn}%
\stepcounter{page}}{}{\errmessage{no}}
\def\fn#1#2{% insert see if \seeentry is not empty
\hyperpage{#2}%
\expandafter\ifx\csname mtfnexiste\@secondoftwo#2\endcsname\relax
\,n.\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
\else
\space n.\,#1\ifx\seeentry\empty\else\seesep\seetext\seeentry\def\seeentry{}\fi%
\fi
}%
\makeatother
% Redefining \index to mark reff. to notes as such.
\LetLtxMacro{\oldindex}{\index}
\renewcommand{\index}[1]{%
\if@noftnote%
\oldindex{#1}%
\else%
\oldindex{#1|fn{\number\value{footnote}}}
\fi%
}
\begin{document}
\lipsum[1-2]
\footnote{bla bla}
\lipsum[1-2]
\footnote{very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
very very long long footnote very very long long footnote
cake\index{cake}}
\lipsum[1-2]
\footnote{last bla bla}
\printindex
\end{document}