2

On this question I have asked how to customize backref to emulate Wikipedia ones. The answer works almost perfect but has a strange behaviour in one case. The problem is with \fullcite. Here an image of how this code works:

image

The problem is that the circled hyperlink should not appear there because is an hyperlink to itself..

Here I provide the code as a 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}

Any idea if it can be solved?

moewe
  • 175,683

1 Answers1

3

Simply replace

\renewbibmacro*{begentry}{\usebibmacro{wikipageref}}

with

\renewbibmacro*{begentry}{\ifcitation{}{\usebibmacro{wikipageref}}}

Since \fullcite uses the bibliography driver, the begentry macro is called, even though we don't want that here.


Starting with version 3.8 of biblatex (not yet released, see https://github.com/plk/biblatex/issues/531) you can use

\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

with the original definition of begentry (\renewbibmacro*{begentry}{\usebibmacro{wikipageref}}).

Here we simply add code to suppress wikipageref in the \usedriver command used by \fullcite.

moewe
  • 175,683