关于这个问题我曾问过如何自定义backref
以模仿维基百科。答案几乎完美,但在一种情况下出现了奇怪的行为。问题出在\fullcite
。下面是此代码如何工作的图像:
问题是带圆圈的超链接不应该出现在那里,因为它是一个指向其自身的超链接。
这里我以 MWE 的形式提供代码:
\documentclass[12pt,twoside]{report}
\usepackage[headheight=18pt,a4paper, width=150mm, top=25mm, bottom=25mm, bindingoffset=6mm, headsep=18pt]{geometry}
\usepackage[spanish,es-noquoting]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes} %"para citar bien"
\usepackage{notoccite}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{AspuruGuz-thermoQM2014,
Title = {Quantum chemical approach to estimating the thermodynamics of metabolic reactions},
Author = {Jinich, Adrian and Rappoport, Dmitrij and Dunn, Ian and Sanchez-Lengeling, Benjamin and Olivares-Amaya, Roberto and Noor, Elad and Even, Arren Bar and Aspuru-Guzik, Alan},
Year = {2014},
Pages = {7022},
Volume = {4},
Journal = {Scientific reports},
Publisher = {Nature Publishing Group}
}
@Article{glyoxal_reaction,
Title = {Thermodynamics and kinetics of glyoxal dimer formation: a computational study},
Author = {Kua, Jeremy and Hanley, Sean W and De Haan, David O},
Year = {2008},
Number = {1},
Pages = {66--72},
Volume = {112},
Journal = {The Journal of Physical Chemistry A},
Publisher = {ACS Publications}
}
\end{filecontents}
\usepackage[style=numeric-comp, backend=biber]{biblatex}
\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
{\usebibmacro{cite:init}%
\let\multicitedelim=\supercitedelim
\iffieldundef{prenote}
{}
{\BibliographyWarning{Ignoring prenote argument}}%
\iffieldundef{postnote}
{}
{\BibliographyWarning{Ignoring postnote argument}}%
\bibopenbracket}%
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}\bibclosebracket}
\let\cite=\supercite
\makeatletter
\DeclareFieldFormat{bibhypertarget}{%
\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{#1}}
\renewbibmacro*{cite:comp}{%
\addtocounter{cbx@tempcntb}{1}%
\ifcsundef{cbx@wikibackref@\thefield{entrykey}}
{\csdef{cbx@wikibackref@\thefield{entrykey}}{}}
{}%
\listcsxadd{cbx@wikibackref@\thefield{entrykey}}{\the\value{instcount}}%
\printtext[bibhypertarget]{%
\iffieldundef{shorthand}
{\ifbool{bbx:subentry}
{\iffieldundef{entrysetcount}
{\usebibmacro{cite:comp:comp}}
{\usebibmacro{cite:comp:inset}}}
{\usebibmacro{cite:comp:comp}}}
{\usebibmacro{cite:comp:shand}}}}
\makeatother
\renewbibmacro*{begentry}{\usebibmacro{wikipageref}}
\newcounter{wikirefitemcount}
\renewcommand{\thewikirefitemcount}{\alph{wikirefitemcount}}
\newbibmacro*{wikipageref}{%
\ifcsundef{cbx@wikibackref@\thefield{entrykey}}
{}
{\setcounter{wikirefitemcount}{0}%
\renewcommand*{\do}[1]{\stepcounter{wikirefitemcount}}%
\dolistcsloop{cbx@wikibackref@\thefield{entrykey}}%
\ifnumgreater{\value{wikirefitemcount}}{1}
{\setcounter{wikirefitemcount}{0}%
\renewcommand*{\do}[1]{%
\stepcounter{wikirefitemcount}%
\mkbibsuperscript{%
\bibhyperlink{\thefield{entrykey}:##1}{\thewikirefitemcount}\addspace}}%
$\uparrow$\addspace\dolistcsloop{cbx@wikibackref@\thefield{entrykey}}}
{\renewcommand*{\do}[1]{\bibhyperlink{\thefield{entrykey}:##1}{$\uparrow$}\addspace}%
\dolistcsloop{cbx@wikibackref@\thefield{entrykey}}}}}
\addbibresource{\jobname.bib}
\begin{document}
Example of citation \cite{AspuruGuz-thermoQM2014,glyoxal_reaction} adbfòkm+\fullcite{AspuruGuz-thermoQM2014} afbadf\footfullcite{AspuruGuz-thermoQM2014}
\end{document}
有什么办法可以解决这个问题吗?
答案1
只需更换
\renewbibmacro*{begentry}{\usebibmacro{wikipageref}}
和
\renewbibmacro*{begentry}{\ifcitation{}{\usebibmacro{wikipageref}}}
由于\fullcite
使用了参考书目驱动程序,因此begentry
调用了宏,尽管我们在这里并不想要它。
从 3.8 版开始biblatex
(尚未发布,请参阅https://github.com/plk/biblatex/issues/531) 您可以使用
\makeatletter
\AtUsedriver{%
\let\finentry\blx@finentry@usedrv
\let\newblock\relax
\let\abx@macro@bibindex\@empty
\let\abx@macro@pageref\@empty
\let\abx@macro@wikipageref\@empty}
\makeatother
与原定义一致begentry
(\renewbibmacro*{begentry}{\usebibmacro{wikipageref}}
)。
这里我们只需在所使用的命令wikipageref
中添加代码来抑制。\usedriver
\fullcite