![自定义参考书目的超链接发送至文档顶部](https://linux22.com/image/463109/%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%E7%9A%84%E8%B6%85%E9%93%BE%E6%8E%A5%E5%8F%91%E9%80%81%E8%87%B3%E6%96%87%E6%A1%A3%E9%A1%B6%E9%83%A8.png)
我使用它来在我的文档中创建参考文献的自定义显示:
\DeclareCiteCommand{\citehyperref}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\ifhyperref
{\hyperlink{\thefield{entrykey}}{\usebibmacro{title}\printtext[parens]{\printfield{year}}}}
{\usebibmacro{title}\printtext[parens]{\printfield{year}}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareFieldFormat[article,book,inbook,incollection,inproceedings,patent,thesis,unpublished]{title}{\printnames{author}\addcolon\space\textit{#1}\isdot}
我想要:一个带有“姓氏,名字:标题(日期)”的超链接。唯一的问题是,超链接指向文档顶部,而不是文档末尾参考书目中的相应参考资料。
我该如何解决这个问题?提前致谢。
编辑:
.tex 文件:
\documentclass[twoside,openright,12pt]{report}
\usepackage[a4paper,left=2cm,right=2cm,top=2cm,bottom=3cm]{geometry}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
% BIBLIOGRAPHY
%\usepackage{natbib} % première bibliographie
\usepackage{csquotes}
\usepackage[style=authoryear-icomp,autolang=hyphen]{biblatex}
\addbibresource{essai.bib}
\DeclareCiteCommand{\citehyperref}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\ifhyperref
{\hyperlink{\thefield{entrykey}}{\usebibmacro{title}\printtext[parens]{\printfield{year}}}}
{\usebibmacro{title}\printtext[parens]{\printfield{year}}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareFieldFormat[article,book,inbook,incollection,inproceedings,patent,thesis,unpublished]{title}{\printnames{author}\addcolon\space\textit{#1}\isdot}
\usepackage{setspace}
\usepackage[french]{babel}
\usepackage[pdftex]{graphicx}
\usepackage{float}
\usepackage{epigraph}
\begin{document}
This is a citation
\citehyperref{MY_REF}
\newpage
\newpage
\newpage
\addcontentsline{toc}{chapter}{Bibliographie}
\chaptermark{Bibliographie}
\printbibheading
\printbibliography
\end{document}
这是我的.bib 文件:
@book{MY_REF,
title = {TITLE},
isbn = {2-7578-2258-6},
pagetotal = {312},
publisher = {Points documents},
author = {XXX, YYY},
urldate = {2023-03-11},
date = {2011-04-21},
}
答案1
biblatex 提供\bibhyperref
处理链接的功能。如果不使用 hyperref,它也能工作:
\documentclass{report}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[style=authoryear-icomp,autolang=hyphen]{biblatex}
\addbibresource{test.bib}
\DeclareCiteCommand{\citehyperref}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\bibhyperref{\usebibmacro{title}\printtext[parens]{\printfield{year}}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareFieldFormat[article,book,inbook,incollection,inproceedings,patent,thesis,unpublished]{title}{\printnames{author}\addcolon\space\textit{#1}\isdot}
\usepackage{hyperref}
\begin{document}
This is a citation
\citehyperref{shepard_absolument_2011}
\newpage
\printbibliography[heading=bibintoc]
\end{document}