我想知道是否有办法通过 \citefield 命令获取链接和反向引用链接。例如,我只想引用参考文献的标题:
\citefield{ref}{title}
或任何其他字段,并获取指向引用的超链接和相应的反向引用链接。
编辑:
平均能量损失
\documentclass{article}
\usepackage[backref=true]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Some text \cite{A01,B02}.
\newpage
In this cite \citefield{A01}{title} I do not get any link
\clearpage
Some more text \cite{A01}.
\printbibliography
\end{document}
答案1
由于这是较低层次的另一种方法,因此我将把它写为另一个答案。
您还可以\citefield
使用xpatch
-package 修补 -command。因此,您只需找到它将调用的底层宏:\blx@cite@citefield
您将无法\citefield{author}
按需要使用,因为它在内部不是作为field
而是作为处理,因此如果您想使用 ,name
您还必须修补。此行中的第三个命令是您可能还必须修补的。请参阅。\citename
\citename{key}{author}
\citelist
biblatex-manual, 3.7.7 Low-level Commands
我的示例包含所有三个补丁,但\citename
仅\citelist
在注释中且未经测试。(以这种方式使用它们对我来说没有多大意义。)
如果你真的想要一个像这样的命令\citeany{key}{field/name/list}
,我想你必须实现一个带有内部开关的新宏,该开关会根据给定的 指向宏、。\citefield
但这相当困难,因为你必须处理来自 cite 命令的 5 个可选参数。我不知道该怎么做。\citekey
\citelist
field/name/list
\documentclass{article}
\usepackage[backref=true,backend=biber]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\usepackage{silence}\WarningFilter{latex}{Overwriting file}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
url = {http://www.something.com}
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\usepackage{xpatch}
\xpatchcmd{\blx@cite@citefield}{\printfield[#4]{#5}}{\printtext[bibhyperref]{\printfield[#4]{#5}}}{}{}%patch \citefield
% \xpatchcmd{\blx@cite@citename}{\printnames[#4]{#5}}{\printtext[bibhyperref]{\printnames[#4]{#5}}}{}{}%patch \citename
% \xpatchcmd{\blx@cite@citelist}{\printlist[#4]{#5}}{\printtext[bibhyperref]{\printlist[#4]{#5}}}{}{}%patch \citelist
\begin{document}
Citefield A01 title: \citefield{A01}{title}.
\clearpage
Citefield B02 title: \citefield{B02}{title}.
Citefield A01 url: \citefield{A01}{url}.
\printbibliography
\end{document}
答案2
我不知道 的解决方案\citefield
。但您可以声明一个新的citecommand
,它将打印出特定的所需字段。在下面的示例中,我声明了一个新的 citecommand \citetitle*
(我不知道如何覆盖\citetitle
)。然后您只需将 包装\printtext[bibhyperref]
在输出周围即可\printfield...
梅威瑟:
\documentclass{article}
\usepackage[backref=true]{biblatex}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareCiteCommand*{\citetitle}%your new citecommand \citetitle*
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexfield{indextitle}}
{}%
\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}%like \citetile,
%only added \printtext[bibhyperref]{...} in this line
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
Some text \cite{A01,B02}.
\newpage
In this cite \citetitle*{A01} I do get a link now.
\clearpage
Some more text \cite{A01}.
\printbibliography
\end{document}