仅显示 Biblatex 引文中的最后两年数字

仅显示 Biblatex 引文中的最后两年数字

我正在写一篇文章,其中引用了几个标准,例如

@STANDARD{en1990,
  title = {EN 1990: Eurocode: Basis of Structural Design},
  organization = {Comit\'e Europ\'een de Normalisation (CEN)},
  address = {Brussels, Belgium},
  year = {2002}
}

@STANDARD{aci318-63,
  title = {ACI 318-63: Building Code Requirements for Reinforced Concrete},
  organization = {American Concrete Institute (ACI)},
  address = {Farmington Hills, Michigan, USA},
  year = {1963}
}

我使用biblatexstyle=authoryear我可以将第一个引用为\parencite*[EN 1990:][]{en1990},这会导致引用以连续文本的形式出现(EN 1990: 2002),这是此标准通常的引用方式。但是,这对第二个示例不起作用,因为此标准的样式为 ,ACI 318-63并且\parencite*只会显示整个年份,而不是仅显示最后几位数字。

有没有办法改变某个引文的年份格式?甚至有没有办法覆盖/修改默认引文文本?

我有点怀疑我需要创建一种自定义样式,并带有一个额外的字段来保存应该出现在引用中的格式化年份,但我希望有一种简单的方法来做到这一点,而不必花费太多时间自定义biblatex样式。

答案1

我不会使用第二个可选的引用参数来生成“短标题”,而是使用字段shorttitle。然后,根据您是否添加了年份的最后几位数字shorttitle,我将使用\parencite(无星号版本)或自定义\parencitetitle命令。

\documentclass{article}

\usepackage[style=authoryear]{biblatex}

\DeclareCiteCommand{\parencitetitle}[\mkbibparens]
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
%   \printfield[citetitle]{labeltitle}}
   \printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencitetitle}[\mkbibparens]
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
%   \printfield[citetitle]{title}}
   \printtext[bibhyperref]{\printfield[citetitle]{title}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\usepackage{hyperref}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@STANDARD{en1990,
  shorttitle = {EN 1990},
  title = {EN 1990: Eurocode: Basis of Structural Design},
  organization = {Comit\'e Europ\'een de Normalisation (CEN)},
  address = {Brussels, Belgium},
  year = {2002},
}
@STANDARD{aci318-63,
  shorttitle = {ACI 318-63},
  title = {ACI 318-63: Building Code Requirements for Reinforced Concrete},
  organization = {American Concrete Institute (ACI)},
  address = {Farmington Hills, Michigan, USA},
  year = {1963},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

Some text \parencite{en1990}.

Some text \parencite{aci318-63}.

Some text \parencitetitle{en1990}.

Some text \parencitetitle{aci318-63}.

\printbibliography

\end{document}

在此处输入图片描述

答案2

您可以定义一个新的格式指令来打印一年的最后两位数字,但您需要自定义样式以将其纳入其中。

使用构成引文标签的字段是避免样式更改的另一种方法。当或不可用时,该label字段可用作后备。该字段将覆盖整个引文标签。authoryearauthoryearshorthand

以下文档给出了一些示例。您可能希望尝试使用labelshorthand和字段titleexecute以避免参考书目中的数据重复。

\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=authoryear]{biblatex}
\usepackage[colorlinks]{hyperref}
\usepackage{xpatch}% Only needed for optional patch below

\DeclareFieldFormat{shortyear}{\mkbibshortyear#1}
\def\mkbibshortyear#1#2#3#4{#3#4}

\newrobustcmd*{\citeshortyear}{%
  \AtNextCite{\DeclareFieldAlias{year}{shortyear}}%
  \citeyear}

% Customize label-year delimiter in cite bibmacro
\newcommand*{\labelyeardelim}{\addspace}
\xpatchbibmacro{cite}
  {\setunit{\addspace}}{\setunit{\labelyeardelim}}{}{}

\begin{filecontents}{\jobname.bib}
@STANDARD{en1990,
  shorthand = {EN 1990: 2001},
  execute = {\ifbibliography{\clearfield{year}}{}},
  title = {Eurocode: Basis of Structural Design},
  organization = {Comit\'e Europ\'een de Normalisation (CEN)},
  address = {Brussels, Belgium},
  year = {2001}}
@STANDARD{en1990label,
  label = {EN 1990},
  execute = {\renewcommand*{\labelyeardelim}{\addcolon\space}},
  title = {Eurocode: Basis of Structural Design},
  organization = {Comit\'e Europ\'een de Normalisation (CEN)},
  address = {Brussels, Belgium},
  year = {2002}}
@STANDARD{aci318-63,
  shorthand = {ACI 318-63},
  title = {Building Code Requirements for Reinforced Concrete},
  organization = {American Concrete Institute (ACI)},
  address = {Farmington Hills, Michigan, USA},
  year = {1963}}
\end{filecontents}
\addbibresource{\jobname.bib}

\newcommand{\cmd}[1]{\texttt{\textbackslash #1}}
\setlength{\parindent}{0pt}

\begin{document}
\cmd{citeyear}: \citeyear{en1990,en1990label,aci318-63} \\
\cmd{citeshortyear}: \citeshortyear{en1990,en1990label,aci318-63} \\
\cmd{parencite}: \parencite{en1990,en1990label,,aci318-63} \\
\cmd{textcite}: \textcite{en1990,en1990label,aci318-63}
\printbibliography
\end{document}

在此处输入图片描述

相关内容