如何修改 citeyear 命令以在括号中包含几个可点击的年份?

如何修改 citeyear 命令以在括号中包含几个可点击的年份?

我有一个References.bib包含如下两个条目的文件:

@article{hartmascolell,
    author = "Sergiu Hart and Andreu Mas-Colell",
    title = "Bargaining and Value",
    journal = "Econometrica",
    volume = "64",
    number = "2",
    pages = "357 -- 380",
    year = "1996",
    url = "https://doi.org/10.2307/2171787"
}

@article{hartmascolell2,
    author = "Sergiu Hart and Andreu Mas-Colell",
    title = "Potential, Value, and Consistency",
    journal = "Econometrica",
    volume = "57",
    number = "3",
    pages = "589 -- 614",
    year = "1989",
    url = "https://doi.org/10.2307/1911054"
}

然后我有了我的主文档,其中我定义了一种自定义样式,citeyearpar将我的引用年份设为可点击的超链接。

\documentclass{article}
\usepackage[]{biblatex}
\usepackage[colorlinks=true]{hyperref}

\addbibresource{References.bib}

% REDEFINING CITEYEAR

\DeclareCiteCommand{\citeyear}
    {}
    {\bibhyperref{\printdate}}
    {\multicitedelim}
    {}

\DeclareCiteCommand{\citeyearpar}
    {}
    {\mkbibparens{\bibhyperref{\printdate}}}
    {\multicitedelim}
    {}

\begin{document}

\citeauthor{hartmascolell}'s \citeyearpar{hartmascolell2,hartmascolell} approach...

\end{document}

输出如下:

在此处输入图片描述

我希望有 (1989, 1996),而不是 (1989),(1996)。我怎样才能做到这一点?另外,我怎样才能更改分隔符(即得到“(1989;1996)”而不是“(1989,1996)”?

答案1

这个怎么样?

\documentclass{article}
\usepackage[]{biblatex}
\usepackage[colorlinks=true]{hyperref}

\addbibresource{References.bib}

% REDEFINING CITEYEAR

\DeclareCiteCommand{\citeyear}
    {}
    {\bibhyperref{\printdate}}
    {\multicitedelim}
    {}

\DeclareCiteCommand{\citeyearpar}
    {\bibopenparen}
    {\bibhyperref{\printdate}}
    {;}
    {\bibcloseparen}

\begin{document}

\citeauthor{hartmascolell}'s \citeyearpar{hartmascolell2,hartmascolell} approach...

\end{document}

在此处输入图片描述

答案2

如果您想要作者年份引文,则应使用\parencite*省略作者姓名的括号引文。对于“压缩”输出,您需要-comp类似这样的样式authoryear-comp

这种方法的优点是,当你改变引用样式时,它也能很好地工作。此外,它在标记中稍微更具语义性。

\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage[colorlinks=true]{hyperref}

\addbibresource{biblatex-examples.bib}

\begin{document}
\Citeauthor{knuth:ct:a}'s \parencite*{knuth:ct:a,knuth:ct:b} approach\dots

\Textcite{knuth:ct:a,knuth:ct:b} showed\dots

\printbibliography
\end{document}

Knuth (1984, 1986) 的方法...Knuth (1984, 1986) 表明...

相关内容