我想\index{entry}
在书目项目内使用。当我引用此项目时,它会出现在当前页面的文本中(我使用style=verbose-trad1
),也会出现在打印完整书目的页面上。我想从索引中删除与\printbibliography
章节相关的页码。
梅威瑟:
\documentclass{article}
\usepackage[style=verbose-trad1]{biblatex}
\usepackage{imakeidx}
\makeindex
\begin{filecontents}{\jobname.bib}
@book{a1,
author = {Aniston, John},
title = {Be happy},
location = {London\index{London}},
date = {1953},
pagetotal = {100},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Lorem \autocite{a1}.
\clearpage
\printbibliography
\printindex
\end{document}
在索引中,我们可以看到页码 1(因为第 1 页有引用)和 2(因为出现在参考书目中)。如何从索引中删除第 2 页?
答案1
我建议你使用一个新命令,比如说\citeindex
。然后我们可以重新定义该命令,让它在参考书目中不执行任何操作
\documentclass{article}
\usepackage[style=verbose-trad1]{biblatex}
\usepackage{imakeidx}
\makeindex
\newcommand*{\citeindex}{\index}
\AtBeginBibliography{\renewcommand*{\citeindex}[1]{}}
\begin{filecontents}{\jobname.bib}
@book{a1,
author = {Aniston, John},
title = {Be happy},
location = {London\citeindex{London}},
date = {1953},
pagetotal = {100},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Lorem \autocite{a1}.
\clearpage
\printbibliography
\printindex
\end{document}
请注意,您可以让biblatex
该location
字段自动建立索引,例如
\documentclass{article}
\usepackage[style=verbose-trad1, indexing=cite]{biblatex}
\usepackage{imakeidx}
\makeindex
\renewbibmacro*{citeindex}{%
\ifciteindex
{\indexnames{labelname}%
\indexfield{indextitle}%
\ifciteseen
{}
{\indexlist{location}}}
{}}
\begin{filecontents}[force]{\jobname.bib}
@book{a1,
author = {Aniston, John},
title = {Be happy},
location = {London},
date = {1953},
pagetotal = {100},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Lorem \autocite{a1}.
\clearpage
\printbibliography
\printindex
\end{document}