我无法理解现有的例子,例如这。
我正在使用ekdosis
依赖于的包verse
,最终lineno
为基于长诗的文档生成行号。现在我得到了以下命令的帮助,但我无法获得正确的结果,该结果应为“rose, 1, 4, 8”。我得到的是“rose, 8”:
\documentclass{report}
\usepackage{imakeidx}
\usepackage{xpatch}
\usepackage{ekdosis}
\makeindex
\makeatletter
\newcommand{\lineindex}[1]{\linelabel{#1}\index{#1}}
\patchcmd{\@wrindex}{\thepage}{\getrefnumber{#2}}{}{}
\makeatother
\begin{document}
\begin{ekdosis}
\begin{ekdverse}
The rose is a rose,\lineindex{rose} \\*
And was always a rose. \\*
But the theory now goes \\*
That the apple's a rose,\lineindex{rose} \\*
And the pear is, and so's \\*
The plum, I suppose. \\*
The dear only knows \\*
What will next prove a rose.\lineindex{rose} \\*
You, of course, are a rose - \\*
But were always a rose.\\*
Robert Frost\\*
\end{ekdverse}
\end{ekdosis}
\printindex
\end{document}
答案1
如果ekdosis
加载了[poetry=verse]
,就像这样:\usepackage[poetry=verse]{ekdosis}
,这应该可以工作:
\documentclass{report}
\usepackage{imakeidx}
\usepackage{xpatch}
\usepackage[poetry=verse]{ekdosis}
\makeindex
\makeatletter
\patchcmd{\@wrindex}{\thepage}{\thepoemline}{}{}
\makeatother
\begin{document}
\begin{ekdosis}
\begin{ekdverse}
The rose is a rose,\index{rose} \\*
And was always a rose. \\*
But the theory now goes \\*
That the apple's a rose,\index{rose} \\*
And the pear is, and so's \\*
The plum, I suppose. \\*
The dear only knows \\*
What will next prove a rose.\index{rose} \\*
You, of course, are a rose - \\*
But were always a rose.\\*
Robert Frost\\*
\end{ekdverse}
\end{ekdosis}
\printindex
\end{document}