我使用 BibLaTeX 来参考文献,但正如您在附图中看到的,它只对年份进行着色和链接,而没有对其余部分进行着色和链接。这是为什么?我该如何改变?
平均能量损失
\documentclass{book}
\usepackage{fontspec}
\setmainfont
[%
Path = Fonts/NotoSans/,
UprightFont = *Regular,
BoldFont = *Bold,
ItalicFont = *Italic,
BoldItalicFont = *BoldItalic
]{NotoSans.ttf}
\usepackage[greek, english]{babel}
\usepackage{csquotes}
\usepackage[style=apa]{biblatex}
\DeclareLanguageMapping{english}{english-apa}
\DeclareLanguageMapping{greek}{greek-apa}
\addbibresource{Bibliography.bib}
\usepackage[
colorlinks,
citecolor=blue,
urlcolor=blue,
bookmarks=false,
hypertexnames=true
]{hyperref}
\begin{document}
Text \parencite{author1}
\printbibliography
\addcontentsline{toc}{chapter}{Bibliography}
\end{document}
围兜
@book{author1,
title={Book Title},
author={Author},
year={2014},
publisher={Publisher}
}
答案1
正如我在评论中写道,我认为我们无法解释为什么结论。事实上,所有biblatex
标准样式都只链接年份(作者-年份样式或作者-标题样式中的标题)。随着时间的推移,人们提出了各种论点,这些论点都归结为说,这允许在-comp
可能的情况下进行明确的链接,在这种情况下,我们
克努斯(1984、1986)
(如果我们也想在这里链接作者,那么应该链接到 1984 年还是 1986 年的作品?)
当然,你是否接受这个说法则是另外一个问题。
无论如何,我可以自信地说,仅链接年份的解决方案更容易实现,并避免了可能出现问题的不幸边缘情况。对于简单的\parencite
in来说,这可能不是立即显而易见的,但instyle=authoryear
的实现中有很多微妙之处,例如,这使得完整链接变得更加棘手。这主要与标点符号缓冲区的使用和生成链接的确切范围有关。\textcite
style=authoryear-comp,
链接和引用颜色面临相同的潜在问题,因此我们可以看看仅针对选定键的自定义引文(彩色)尝试看看我们能否让更多链接以 APA 格式工作。我认为以下解决方案是最简洁的解决方案,它可以生成尽可能完整的链接,而无需重写工作中的大量代码biblatex-apa
。
请注意,biblatex-apa
代码可能会发生变化。此处的代码可能不适用于所有版本。它已使用 v9.16(2022/06/22)进行了测试。如果此代码不再适用于biblatex-apa
CTAN 上的当前版本,请发表评论。
\documentclass{article}
\usepackage[style=apa,backend=biber]{biblatex}
\usepackage{hyperref}
\makeatletter
\renewbibmacro*{cite:author}{%
\iffieldequals{namehash}{\cbx@lasthash}
% Multiple cites in one command
{\setunit{\compcitedelim}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}%
% Single cite
{\printtext[bibhyperref]{%
\ifnameundef{labelname}
% No author/editor
{\usebibmacro{cite:noname}%
\savefield{namehash}{\cbx@lasthash}}
% Normal cite
{\ifnameundef{shortauthor}
{\printnames{labelname}}%
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
{\printnames[labelname]{author}%
\addspace\printnames[sabrackets]{shortauthor}}}%
\savefield{namehash}{\cbx@lasthash}}}}%
\setunit{\multicitedelim}}
\renewbibmacro*{cite}{%
\iffieldequals{namehash}{\cbx@lasthash}
% Multiple cites in one command
{\setunit{\compcitedelim}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}%
% Single cite
{\printtext[bibhyperref]{%
\ifnameundef{labelname}
% No author/editor
{\usebibmacro{cite:noname}%
\setunit{\printdelim{nameyeardelim}}%
\usebibmacro{cite:plabelyear+extradate}%
\savefield{namehash}{\cbx@lasthash}}
% Normal cite
{\ifnameundef{shortauthor}
{\printnames{labelname}}%
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
{\printnames[labelname]{author}%
\addspace\printnames[sabrackets]{shortauthor}}}%
\setunit{\printdelim{nameyeardelim}}%
\usebibmacro{cite:plabelyear+extradate}%
\savefield{namehash}{\cbx@lasthash}}}}%
\setunit{\multicitedelim}}
\renewbibmacro*{textcite}{%
\iffieldequals{namehash}{\cbx@lasthash}
% Compact cite - more than one thing for same author
{\setunit{\compcitedelim}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}
% New cite
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\setunit{\textcitedelim}%
\ifnameundef{labelname}
% No author/editor
{\iffieldundef{shorthand}%
% Cite using title
{\printtext[bibhyperref]{\usebibmacro{cite:noname}}%
\setunit{\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}%
\bibopenparen}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}
% Cite using shorthand
{\printtext[bibhyperref]{%
\usebibmacro{cite:shorthand}}}}
% Normal cite with author/editor
% Normal full cite
{\printtext[bibhyperref]{%
\ifnameundef{shortauthor}%
% Normal full cite
{\printnames{labelname}}
% Cite using short author
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
{\printnames[labelname]{author}}}}%
% Year
\setunit{\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}%
\bibopenparen}%
% Put the shortauthor inside the year brackets if necessary
\printtext[bibhyperref]{%
\ifnameundef{shortauthor}
{}
{\cbx@apa@ifnamesaved
{}
{\printnames{shortauthor}%
\setunit{\printdelim{innernameyeardelim}}}}%
% Print prenote (belongs to first cite)
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
% Actual year printing
\usebibmacro{cite:plabelyear+extradate}%
% Save name hash for checks later
\savefield{namehash}{\cbx@lasthash}}%
\stepcounter{textcitecount}}}}
\renewbibmacro*{cite:plabelyear+extradate}{%
\iffieldundef{labelyear}{}
{\clearfield{labelmonth}% don't want months in citations
\clearfield{labelday}% don't want days in citations
\clearfield{labelendmonth}% don't want months in citations
\clearfield{labelendday}% don't want days in citations
\clearfield{labelyeardivision}% don't want yeardivisions in citations
\clearfield{labelendyeardivision}% don't want yeardivisions in citations
\iffieldsequal{labelyear}{labelendyear}% Don't want no-op year ranges
{\clearfield{labelendyear}}
{}%
\iffieldundef{origyear}
{}
{\printorigdate%
\setunit*{\addslash}}%
\iffieldundef{related}
{}
{\iffieldequalstr{relatedtype}{reprintfrom}
{\entrydata*{\thefield{related}}{\printlabeldateextra}%
\setunit*{\addslash}}
{}}%
\printlabeldateextra}}
\renewbibmacro*{citeyear}{%
\iffieldundef{labelyear}
{\usebibmacro{cite:init}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\setunit{\compcitedelim}%
\printtext[bibhyperref]{\usebibmacro{cite:plabelyear+extradate}}}
{\printtext[bibhyperref]{\usebibmacro{cite:plabelyear+extradate}}%
\savefield{namehash}{\cbx@lasthash}}}%
\setunit{\multicitedelim}}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
Lorem \parencite{sigfridsson}
ipsum \parencite{knuth:ct:a,knuth:ct:b}
dolor \parencite{nussbaum,geer,worman}
Lorem \textcite{sigfridsson}
ipsum \textcite{knuth:ct:a,knuth:ct:b}
dolor \textcite{nussbaum,geer,worman}
\printbibliography
\end{document}