2

I want postnotes for inline citations to be hyperlinked, i.e. I want the authorname, year, and any postnotes hyperlinked (but not prenotes!).

I've used the answer here to get authorname hyperlinked, but can't figure out how to add the postnote to the hyperlink.

MWE:

\documentclass{article} 
\usepackage[utf8]{inputenc} 
\usepackage[style=authoryear-comp,backend=bibtex,hyperref]{biblatex} 
\usepackage[colorlinks]{hyperref}
\addbibresource{biblatex-examples.bib}


\makeatletter
%Works without the last bracket ;-)
\let\abx@macro@citeOrig\abx@macro@cite
\renewbibmacro{cite}{%
\bibhyperref{%
\let\bibhyperref\relax\relax%
\abx@macro@citeOrig%
  }%
}
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{%
  \bibhyperref{%
    \let\bibhyperref\relax\relax%
    \abx@macro@textciteOrig%
  }%
}%
\makeatother


\begin{document} 
A reference to \parencite[e.g.][3-4]{kastenholz}, \parencite[56]{bertram}, and~\textcite[12-14]{sigfridsson}.  
\printbibliography 
\end{document}

In the above example, ", pp.3-4" and ", p.56" should be hyperlinked for Kastenholz and Bertram, respectively (not the parentheses), while ", pp. 12-14)" should be hyperlinked for the Sigfridsson cite (parentheses included).

Any suggestions?

P.S. I'm compiling this in RStudio, which requires me to use backend=bibtex, so any solution must allow for that.

0

Here is a way: (answering after years because @aan user found that non answered question in a related question from him/her)

\documentclass{article} 
\usepackage[utf8]{inputenc} 
\usepackage[style=authoryear-comp,backend=bibtex,hyperref]{biblatex} 
\usepackage[colorlinks]{hyperref}
\addbibresource{biblatex-examples.bib}


\makeatletter
%Works without the last bracket ;-)
\let\abx@macro@citeOrig\abx@macro@cite
\renewbibmacro{cite}{%
\bibhyperref{%
\let\bibhyperref\relax\relax%
\abx@macro@citeOrig%
  }%
}
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{%
  \bibhyperref{%
    \let\bibhyperref\relax\relax%
    \abx@macro@textciteOrig%
  }%
}%
\makeatother
\DeclareFieldFormat{postnote}{\printtext[bibhyperref]{#1}}
\DeclareFieldFormat{multipostnote}{\printtext[bibhyperref]{#1}}
\DeclareFieldFormat{prenote}{\printtext[bibhyperref]{#1}}
\DeclareFieldFormat{multiprenote}{\printtext[bibhyperref]{#1}}

\begin{document} 
A reference to \parencite[e.g.][3-4]{kastenholz}, \parencite[56]{bertram}, and~\textcite[12-14]{sigfridsson}.  
\printbibliography 
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.