对于官方报告,我们经常被要求在参考文献部分以粗体显示我们的名称,以及过去 5 年内的出版日期。
我手动编辑了作者列表,用\baptiste
我在序言中定义的宏替换了我的名字,
\newcommand{\baptiste}{\textbf{B. LastName}}
然而,对于日期,我有点困惑。
\begin{filecontents}{\jobname.bib}
@book{Labov1972,
Address = {Philadelphia},
Author = {William Labov},
Publisher = {University of Pennsylvania Press},
Title = {Sociolinguistic Patterns},
Year = {2018}}
@book{Chomsky1957,
Address = {The Hague},
Author = {Noam Chomsky},
Publisher = {Mouton},
Title = {Syntactic Structures},
Year = {1957}}
}
\end{filecontents}
\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Some famous linguists wrote a couple of books \autocite{Labov1972,Chomsky1957}.
\printbibliography
\end{document}
答案1
我只想回答关于日期的问题。粗体名称已在其他地方得到广泛讨论:使用 biblatex 将特定作者设为粗体。
我们可以定义一个\iflastnyears{<n>}
检查字段是否year
属于过去<n>
(完整)年份,这样目前(即 2020 年)\iflastnyears{5}
对于 2015 年到 2020 年(包括 2020 年)都成立。当然,您可以根据自己的喜好调整定义中的逻辑。
请注意,我们必须包含笨重的,\ifdateera{bce}
因为biblatex
不会在字段中保存年份的符号year
,所以它实际上包含\abs{year}
。\ifdateera{bce}
对于 0 年之前的日期(因此对于负日期)是正确的。
\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\makeatletter
% \year should hold the current year, but there are classes
% (and maybe packages) that redefine it :-(
\newcommand*{\iflastnyears}[1]{%
\ifdateera{bce}
{\@secondoftwo}
{\iffieldint{year}
{\ifnumgreater{\thefield{year}}{\year-#1-1}}
{\@secondoftwo}}}
\makeatother
\DeclareFieldFormat{date}{%
\iflastnyears{5}
{\mkbibbold{#1}}
{#1}%
}
\begin{filecontents}{\jobname.bib}
@book{Labov2018,
Address = {Philadelphia},
Author = {William Labov},
Publisher = {University of Pennsylvania Press},
Title = {Sociolinguistic Patterns},
Year = {2018},
}
@book{Chomsky1957,
Address = {The Hague},
Author = {Noam Chomsky},
Publisher = {Mouton},
Title = {Syntactic Structures},
Year = {1957},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Some famous linguists wrote a couple of books \autocite{Labov2018,Chomsky1957}.
\printbibliography
\end{document}
如果你还想突出显示引用中的年份,请添加
\DeclareFieldFormat{labeldate}{%
\ifboolexpr{test {\iflabeldateisdate} and test {\iflastnyears{5}}}
{\mkbibbold{#1}}
{#1}%
}