我想在文档中显示的参考书目之一中显示期刊的排名。也就是说,我需要有选择地打印参考书目项目的字段。note
是我选择这样做的字段。我想到的唯一办法是做一些类似于我对粗体名称的操作,但针对注释字段。然而,我没有成功,因为我无法正确理解手册中“数据注释”的整个部分biblatex
。
以下是我目前所做工作的 MWE:
\documentclass{article}
\usepackage{hyperref}
\usepackage[
backend=biber,
style=numeric-comp,
]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{file.bib}
@article{gillies,
author = {Gillies, Alexander},
author+an = {1=highlight},
title = {Herder and the Preparation of {Goethe's} Idea of World Literature},
journaltitle = {Publications of the English Goethe Society},
date = {1933},
% date+an = {=attributed},
series = {newseries},
volume = {9},
% volume+an = {=attributed},
pages = {46-67},
note = {Q1},
note+an={2=rank}
}
\end{filecontents}
\addbibresource{file.bib}
\begin{document}
\begin{refsection}
%comandos para resaltarme como autor en negrita en mis publicaciones
\renewcommand*{\mkbibnamegiven}[1]{%
\ifitemannotation{highlight}
{\textbf{#1}}
{#1}}
\renewcommand*{\mkbibnamefamily}[1]{%
\ifitemannotation{highlight}
{\textbf{#1}}
{#1}}
\nocite{gillies}
\printbibliography
\end{refsection}
\nocite{gillies}
\printbibliography
\end{document}
如果有人知道如何利用数据属性biblatex
或任何其他方法实现我的目的,我欢迎他们。
答案1
我会使用略有不同的方法。我会定义一个新字段,并使用更符合语义的名称来表示您想要的内容,而不是note
。然后,您可以有选择地注入代码,以在您想要查看字段的参考书目中打印新字段。
对于新字段,我们需要一个数据模型文件 ( .dbx
),另请参阅将字段“tome”添加到 biblatex 条目。
\documentclass{article}
\begin{filecontents*}{rank.dbx}
\ProvidesFile{rank.dbx}[2020/07/05 add rank field]
\DeclareDatamodelFields[type=field,datatype=literal]{rank}
\DeclareDatamodelEntryfields{rank}
\end{filecontents*}
\usepackage[
backend=biber,
style=numeric-comp,
datamodel=rank,
]{biblatex}
\usepackage{hyperref}
\begin{filecontents}{\jobname.bib}
@article{gillies,
author = {Gillies, Alexander},
author+an = {1=highlight},
title = {Herder and the Preparation of {Goethe's} Idea of World Literature},
journaltitle = {Publications of the English Goethe Society},
date = {1933},
series = {newseries},
volume = {9},
pages = {46-67},
rank = {Q1},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\begin{refsection}
\renewcommand*{\mkbibcompletename}[1]{%
\ifitemannotation{highlight}
{\textbf{#1}}
{#1}}
\renewbibmacro*{finentry}{\newunit\newblock\printfield{rank}\finentry}
\nocite{gillies}
\printbibliography
\end{refsection}
\nocite{gillies}
\printbibliography
\end{document}
我不太认为字段注释是这里的最佳解决方案,但它可以做到。我们需要定义一些新的宏,因为\AtEveryBibitem
和\AtBeginBibliography
通常是全局作用的,并且只允许在序言中使用。
这个想法是删除rank
第二个参考书目中所有带有注释的注释字段。
\documentclass{article}
\usepackage[
backend=biber,
style=numeric-comp,
]{biblatex}
\usepackage{hyperref}
\makeatletter
\newrobustcmd*{\LocalAtBeginBibliography}{\appto\blx@hook@bibinit}
\newrobustcmd*{\LocalAtEveryBibitem}{\appto\blx@hook@bibitem}
\makeatother
\begin{filecontents}{\jobname.bib}
@article{gillies,
author = {Gillies, Alexander},
author+an = {1=highlight},
title = {Herder and the Preparation of {Goethe's} Idea of World Literature},
journaltitle = {Publications of the English Goethe Society},
date = {1933},
series = {newseries},
volume = {9},
pages = {46-67},
note = {Q1},
note+an = {=rank},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\begin{refsection}
\renewcommand*{\mkbibcompletename}[1]{%
\ifitemannotation{highlight}
{\textbf{#1}}
{#1}}
\nocite{gillies}
\printbibliography
\end{refsection}
\LocalAtBeginBibliography{%
\LocalAtEveryBibitem{%
\iffieldannotation[note]{rank}
{\clearfield{note}}
{}}}
\nocite{gillies}
\printbibliography
\end{document}
请注意,我使用新的简化了粗体名称的代码\mkbibcompletename
,它适用于完整名称,而不仅适用于\mkbibnamefamily
和等名称部分\mkbibnamegiven
。