Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Biblatex: How to get references from the text (that is, author and/or year) to link to the bibliography record?

2,282 views
Skip to first unread message

mbaer

unread,
Sep 24, 2009, 4:32:31 AM9/24/09
to
Hi everyone,

this issue had been discussed before, but to no avail (http://
groups.google.com/group/comp.text.tex/browse_thread/thread/
bf96eded139d8c49). Hence a second go, this time with a hopefully
better subject line.

The problem is that using \autocite or \textcite only the year gets
hyperlinked to the bib record. Using \citeauthor or \citeyear results
in no linking at all. Why is that? It used to work with bibtex and
hyperref.

Thanks for your help.

Best,
Matthias

Dominik Waßenhoven

unread,
Sep 24, 2009, 5:05:23 AM9/24/09
to
mbaer wrote:

> The problem is that using \autocite or \textcite only the year gets
> hyperlinked to the bib record. Using \citeauthor or \citeyear results
> in no linking at all. Why is that?

It has to do with how the cite commands are build. The standard styles
are designed in a way that the link is set to the unique part of the
citation. In authoryear styles, this is the year (since a label is
added, if an author has more than one publication within a year).

One solution could be to change the corresponding cite commands and
bibmacros (from authoryear.cbx) in order to have the whole citation as a
hyperlink. See the attached example.

8<------------------------------------------------------------>8
\documentclass[english]{scrartcl}
\listfiles
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{article,
author = {Author, Anthony},
title = {An Article},
journal = {Journal},
year = {2006},
volume = {6},
pages = {19--75}
}
@BOOK{book,
author = {Author, Anthony},
title = {A Book},
address = {London},
year = {2000}
}
@BOOK{book2,
author = {Author, Another},
title = {Another Book},
shorthand = {Shorthand},
address = {Berlin},
year = {2004}
}
\end{filecontents}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel,csquotes}

\usepackage[
style=authoryear,
hyperref=true
]{biblatex}
\bibliography{\jobname}

\DeclareCiteCommand{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
{\boolfalse{cbx:parens}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{textcite}}}
{\ifbool{cbx:parens}
{\bibrightparen\global\boolfalse{cbx:parens}}
{}%
\multicitedelim}
{\iffieldundef{postnote}
{\ifbool{cbx:parens}
{\bibrightparen}
{}}
{\ifbool{cbx:parens}
{\postnotedelim}
{\addspace\bibleftparen}%
\printfield{postnote}\bibrightparen}}

\DeclareCiteCommand{\citeauthor}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\indexnames{labelname}%
\printtext[bibhyperref]{\printnames{labelname}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printtext[bibhyperref]{\printfield{year}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\renewbibmacro*{cite:label}{%
\iffieldundef{label}
{\printfield[citetitle]{labeltitle}}
{\printfield{label}}}

\renewbibmacro*{cite:year+labelyear}{%
\iffieldundef{year}
{}
{\printfield{year}%
\printfield{labelyear}}}

\renewbibmacro*{cite:shorthand}{%
\printfield{shorthand}}

\usepackage{hyperref}

\begin{document}
cite: \cite{article,book,book2}

cite*: \cite*{book}

autocite: \autocite{book}

textcite: \textcite[33]{article}

citeauthor/citeyear: \citeauthor{article} (\citeyear{article})

footcite: \footcite[21]{book}

parencite: \parencite{book}

parencite*: \parencite*{article}

\printbibliography
\end{document}
8<------------------------------------------------------------>8

Regards,
Dominik.-
--
UK-TeX-FAQ: http://www.tex.ac.uk/cgi-bin/texfaq2html
minimal example: http://www.minimalbeispiel.de/mini-en.html
biblatex styles: http://biblatex.dominik-wassenhoven.de/?en

mbaer

unread,
Sep 24, 2009, 6:20:23 AM9/24/09
to

Perfect. Works for me. Thanks a million!

leopold....@gmail.com

unread,
Oct 8, 2012, 10:12:03 AM10/8/12
to
thanks for the answer. This works for author-year but it does not seem to work with the numeric options in natbib (using biblatex and natbib=true) as it does when using only natbib (where the \citeauthor output is hyperlinked)

Any idea how to make this work?
0 new messages