我想结合@moewe 的答案,这里和@lockstep,这里,使用 biblatex 获取完全超链接的作者年份引用,如下所示。
\documentclass{memoir}
\usepackage{xcolor}
\usepackage[backend=biber, defernumbers=true, bibstyle=authoryear,style=ext-authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
\end{filecontents}
\bibliography{\jobname.bib}
%to be put citations in brackets
\DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}
%%% To make author hyperlink, just like year, in citations
\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=violet, citecolor=violet]{hyperref}
\begin{document}
\parencite{A01}
\printbibliography
\end{document}
结果是完全超链接,尽管周围的元素是圆括号而不是方括号。
我怎样才能解决这个问题?
答案1
biblatex-ext
通常\DeclareOuterCiteDelims
通过 cite 命令的包装器定义来实现。即\parencite
在标准中定义authoryear.cbx
为
\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
但ext-authoryear.cbx
有
\DeclareCiteCommand{\parencite}[\mkouterparencitedelims]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
因此,如果你重新定义,\parencite
你需要保留\mkouterparencitedelims
。因此,
\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}
必须是
\documentclass{memoir}
\usepackage{xcolor}
\usepackage[backend=biber, style=ext-authoryear]{biblatex}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=violet, citecolor=violet]{hyperref}
\DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}
\DeclareCiteCommand{\parencite}[\mkouterparencitedelims]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\addbibresource{biblatex-examples.bib}
\begin{document}
\parencite{sigfridsson}
\printbibliography
\end{document}
不过,这里有些不对劲。 的定义\parencite
只打印年份 ( \usebibmacro{citeyear}
)。 它看起来更像是 的定义\parencite*
。 要获得完整引文,您需要\usebibmacro{cite}
。
请注意,如果你只是说,你可能会遇到双链接目标的问题
\DeclareCiteCommand{\parencite}[\mkouterparencitedelims]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
就像是
\documentclass{memoir}
\usepackage{xcolor}
\usepackage[backend=biber, style=ext-authoryear]{biblatex}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=violet, citecolor=violet]{hyperref}
\DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\DeclareCiteCommand{\parencite}[\mkouterparencitedelims]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[citehyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\addbibresource{biblatex-examples.bib}
\begin{document}
\parencite{sigfridsson}
\printbibliography
\end{document}
在这方面更安全(见超链接名称与 biblatex 作者年份 (biblatex 1.4b))。