我想将所有引用的作者都包含在索引中,但使用书目标签而不是页码。我试过了authorindex
,但我想要一个索引而不是两个不同的索引。我也试过了,authorindex -i
但 makeindex 不喜欢这个选项,biblabels
因为标签不是正确的页码。
如何获得\index{...}
包含被引作者和相应 bibtex 标签的单一索引(包含条目和被引作者)?
以下是 MWE:
\begin{filecontents*}{\jobname.bib}
@BOOK{Cameron1994,
AUTHOR = {Cameron, Peter Jephson},
TITLE = {{Combinatorics}: {Topics}, {Techniques}, {Algorithms}},
PUBLISHER = {Cambridge University Press},
YEAR = {1994}
}
@ARTICLE{Cameron2008,
AUTHOR = {Cameron, Peter Jephson and Gewurz, Daniele A. and Merola, Francesca},
TITLE = {{Product} action},
JOURNAL = {Discrete Math.},
YEAR = {2008}
}
\end{filecontents*}
\documentclass{article}
\usepackage{makeidx}
\usepackage[biblabels]{authorindex}
\makeindex
\begin{document}
I \index{cite}cite something like \aicite{Cameron1994} and \aicite{Cameron2008}.
I want a \index{merged}merged index.
\bibliographystyle{alpha}
\bibliography{\jobname.bib}
\printindex
\printauthorindex
\end{document}
我编译
pdflatex
bibtex
makeindex
authorindex
pdflatex
authorindex
pdflatex
我得到两个索引(一个用于\printindex
,一个用于\printauthorindex
):
但我想要的是合并索引
为了生成最后的索引,我*.ind
手动操作了文件。
我自己尝试过一个解决方案,但失败了:我曾经将authorindex -i -p MWE >> MWE.idx
作者索引的条目添加到普通索引中。但我无法用 编译它makeindex
,因为“CGM08”(等)不是正确的页码。
答案1
以下解决方案或多或少是一种黑客攻击。但它似乎有效:
\begin{filecontents*}{\jobname.bib}
@BOOK{Cameron1994,
AUTHOR = {Cameron, Peter Jephson},
TITLE = {{Combinatorics}: {Topics}, {Techniques}, {Algorithms}},
PUBLISHER = {Cambridge University Press},
YEAR = {1994}
}
@ARTICLE{Cameron2008,
AUTHOR = {Cameron, Peter Jephson and Gewurz, Daniele A. and Merola, Francesca},
TITLE = {{Product} action},
JOURNAL = {Discrete Math.},
YEAR = {2008}
}
\end{filecontents*}
\documentclass{article}
\usepackage{makeidx}
\usepackage[biblabels]{authorindex}
\makeatletter
\def\gobble#1{}
\renewenvironment{theauthorindex}{%
\begingroup
\let\indexspace\relax
\def\item[##1]{\null\gdef\ItemIndex{##1}}
\def\aipages##1{\index{\ItemIndex @{\ItemIndex~[##1]}\protect\gobble |gobble}}
}{\endgroup}
\makeatother
\makeindex
\begin{document}
I \index{cite}cite something like \aicite{Cameron1994} and \aicite{Cameron2008}.
I want a \index{merged}merged index.
\bibliographystyle{alpha}
\bibliography{\jobname.bib}
\printindex
\printauthorindex
\end{document}
运行以下编译马拉松两次后:
% arara: pdflatex: { shell: true }
% arara: bibtex
% arara: authorindex
% arara: bibtex
% arara: pdflatex: { shell: true }
% arara: authorindex
% arara: makeindex
% arara: pdflatex: { shell: true }
% arara: pdflatex: { shell: true }
我得到以下输出: