根据问题这里,我使用了以下代码
\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usedriver
{\DeclareNameAlias{sortname}{default}}
{\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}
用于生成我的文档作者索引。不幸的是,我正在研究一位作者,并在文中多次引用他的名字,他的名字在索引中出现了很多次。
有什么解决方案可以自动隐藏索引中的特定条目?:-)
梅威瑟:
\documentclass[english]{article}
\listfiles
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{article,
author = {Nachname, Vorname},
title = {Titel des Zeitschriftenartikels},
journal = {Zeitschrift},
year = {2006},
volume = {6},
pages = {19--75}
}
@BOOK{book,
author = {Buchautor, Hans-Wilhelm},
title = {Irgendein Buch},
address = {Buch am Wald},
year = {2000}
}
\end{filecontents}
\usepackage{babel,csquotes}
\usepackage[
texindy
]{indextools}
\makeindex
\makeindex[columnseprule,intoc=true,title=Index,name=perso]
\usepackage[
style=authortitle,
indexing=true
]{biblatex}
\bibliography{\jobname}
\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usedriver
{\DeclareNameAlias{sortname}{default}}
{\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareIndexNameFormat{default}{%
\nameparts{#1}%
\usebibmacro{index:name}%
{\index[perso]}%
{\namepartfamily}%
{\namepartgiveni}%
% {}% L1
% {}% L2
{\namepartprefix}% generates spurious space L3
{\namepartsuffix}% generates spurious space L4
}
\begin{document}
\index[perso]{check}
\index[perso]{checkb}
\index[perso]{check}
\index[perso]{checkb}
\index[perso]{checkb}
\footcite{book}\newpage
\footfullcite{book}\newpage
\cite{article}\newpage
\footcite{article}\newpage
\footfullcite{article}
\printbibliography
\printindex[perso]
\end{document}
答案1
我不太清楚您想排除哪些条目。但您可以相当轻松地向 citeindex 宏添加测试:
\renewbibmacro*{citeindex}{%
\ifciteindex
{\iffieldequalstr{entrykey}{book}{}
{\indexnames{labelname}%
\indexfield{indextitle}}}
{}}
答案2
可能有更好的替代方法,但您可以将类别分配给不应导致索引的键。遗憾的是,这需要更改所有使用的引用宏。以下内容将此更改应用于\footfullcite
您提供的定义。请注意,该键仍显示在参考书目页面的索引中:
\documentclass[english]{article}
%\listfiles
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{article,
author = {Nachname, Vorname},
title = {Titel des Zeitschriftenartikels},
journal = {Zeitschrift},
year = {2006},
volume = {6},
pages = {19--75},
}
@BOOK{book,
author = {Buchautor, Hans-Wilhelm},
title = {Irgendein Buch},
address = {Buch am Wald},
year = {2000}
}
\end{filecontents}
\usepackage{babel,csquotes}
\usepackage[
texindy
]{indextools}
\makeindex
\makeindex[columnseprule,intoc=true,title=Index,name=perso]
\usepackage[
style=authortitle,
indexing=true
]{biblatex}
\bibliography{\jobname}
\DeclareBibliographyCategory{noindex}% create the new category
\addtocategory{noindex}{book}% add the key `book` to that category
\DeclareCiteCommand{\footfullcite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\ifcategory{noindex}{}{\usebibmacro{citeindex}}% only if not in noindex
\usedriver
{\DeclareNameAlias{sortname}{default}}
{\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareIndexNameFormat{default}{%
\nameparts{#1}%
\usebibmacro{index:name}%
{\index[perso]}%
{\namepartfamily}%
{\namepartgiveni}%
% {}% L1
% {}% L2
{\namepartprefix}% generates spurious space L3
{\namepartsuffix}% generates spurious space L4
}
\begin{document}
\footfullcite{book}\newpage
\footfullcite{book}\newpage
\footfullcite{article}\newpage
\footfullcite{article}\newpage
\footfullcite{article}
\printbibliography
\printindex[perso]
\end{document}
要从索引中完全删除键,您可以在定义\ifcategory
中插入检查\DeclareIndexNameFormat
:
\DeclareIndexNameFormat{default}{%
\ifcategory{noindex}{}{
\nameparts{#1}%
\usebibmacro{index:name}%
{\index[perso]}%
{\namepartfamily}%
{\namepartgiveni}%
% {}% L1
% {}% L2
{\namepartprefix}% generates spurious space L3
{\namepartsuffix}% generates spurious space L4
}}
如果你更喜欢这种方法,你可以基于 bib 文件而不是在 tex 文件中通过引入关键字来执行相同的操作。文件的内容\jobname.bib
变为:
\begin{filecontents}{\jobname.bib}
@ARTICLE{article,
author = {Nachname, Vorname},
title = {Titel des Zeitschriftenartikels},
journal = {Zeitschrift},
year = {2006},
volume = {6},
pages = {19--75},
}
@BOOK{book,
author = {Buchautor, Hans-Wilhelm},
title = {Irgendein Buch},
address = {Buch am Wald},
year = {2000},
keywords = {noindex}
}
\end{filecontents}
只需将支票更改\ifcategory
为\ifkeyword
其余部分保持不变。