我在 biblatex 中遇到了一个问题,我需要使用自定义文本字符串而不是标准引文标签(用于显示漂亮的引文)来引用书目条目。我希望镜像中讨论的功能这里,但在 biblatex 包内。
文本中期望的结果类似于:“这应该是可点击的”,指向Doe2019
参考书目列表中的相应条目。
以下是该场景的 MWE(替代方案:背面样本)
\documentclass{article}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{hyperref}
% Inline bibliography entry
\begin{filecontents}[overwrite]{\jobname.bib}
@article{Doe2019,
author = {John Doe},
title = {Title of the Work},
year = {2019},
}
\end{filecontents}
\addbibresource{\jobname.bib}
% Command to link to the bibliography
\newcommand{\citelinktext}[2]{%
\hyperlink{#1}{#2}
}
\begin{document}
I am looking to cite this in a custom manner, for example \citelinktext{Doe2019}{This Should Be Clickable with inner-quotes like \citeyear{Doe2019}}.
\cite{Doe2019}
\clearpage
% Create a hypertarget for the bibliography section
\printbibliography
\end{document}
当我编译时,会出现引文,但单击它只会链接到文档的第一页,而不是参考书目中的指定条目。有人可以指导如何使用 Biblatex 实现自定义文本引文吗?
编辑
使用“嵌套引号”的扩展示例(\citeyear{Doe2019}
)
答案1
这有点作弊(不要将它与键列表一起使用):
\documentclass{article}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{hyperref}
% Inline bibliography entry
\begin{filecontents}[overwrite]{\jobname.bib}
@article{Doe2019,
author = {John Doe},
title = {Title of the Work},
year = {2019},
}
\end{filecontents}
\addbibresource{\jobname.bib}
% Command to link to the bibliography
\makeatletter
\DeclareCiteCommand{\@citelinktext}
{}%
{}
{}
{\printtext[bibhyperref]{\usebibmacro{postnote}}}
\newcommand{\citelinktext}[2]{%
\@citelinktext[#2]{#1}%
}
\makeatother
\begin{document}
I am looking to cite this in a custom manner, for example
\citelinktext{Doe2019}{This Should Be Clickable}. \cite{Doe2019}
\clearpage
% Create a hypertarget for the bibliography section
\printbibliography
\end{document}