1

I am encountering an issue with biblatex where I need to refer to a bibliographic entry using a custom text string instead of the standard citation label (used for displaying beautiful quotes). I wish to mirror the functionality discussed in here, but within the biblatex package.

The desired outcome in the text is something like: "This Should Be Clickable" pointing to the corresponding entry Doe2019 in the bibliography list.

Below is the MWE for the scenario (alternative: Overleaf Sample)

\documentclass{article}

\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{hyperref}

% Inline bibliography entry
\begin{filecontents}[overwrite]{\jobname.bib}
@article{Doe2019,
  author    = {John Doe},
  title     = {Title of the Work},
  year      = {2019},
}
\end{filecontents}
\addbibresource{\jobname.bib}

% Command to link to the bibliography
\newcommand{\citelinktext}[2]{%
   \hyperlink{#1}{#2}
}

\begin{document}

I am looking to cite this in a custom manner, for example \citelinktext{Doe2019}{This Should Be Clickable with inner-quotes like \citeyear{Doe2019}}.
\cite{Doe2019}

\clearpage

% Create a hypertarget for the bibliography section
\printbibliography

\end{document}

When I compile, the citation appears but clicking on it just links to the first page of the document rather than the specified entry in the bibliography. Could anyone guide how to achieve the custom text citation with Biblatex?

EDIT

Extended example with "nested quotes" (\citeyear{Doe2019})

1 Answer 1

3

It is a bit cheating (do not use it with a list of keys):

\documentclass{article}

\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{hyperref}

% Inline bibliography entry
\begin{filecontents}[overwrite]{\jobname.bib}
@article{Doe2019,
  author    = {John Doe},
  title     = {Title of the Work},
  year      = {2019},
}
\end{filecontents}
\addbibresource{\jobname.bib}

% Command to link to the bibliography
\makeatletter
\DeclareCiteCommand{\@citelinktext}
  {}%
  {}
  {}
  {\printtext[bibhyperref]{\usebibmacro{postnote}}}

\newcommand{\citelinktext}[2]{%
   \@citelinktext[#2]{#1}%
}
\makeatother
\begin{document}

I am looking to cite this in a custom manner, for example 
\citelinktext{Doe2019}{This Should Be Clickable}. \cite{Doe2019} 

\clearpage

% Create a hypertarget for the bibliography section
\printbibliography

\end{document}
3
  • Awesome, thanks! By "list of keys" you mean something like \citelinktext{Doe2019, Abc2023}, right?
    – Highnoon
    Nov 7, 2023 at 8:38
  • yes, that wouldn't work (and it would be quite unclear anyway what it should do). (One could insert some test to catch such a case and error if needed). Nov 7, 2023 at 9:09
  • Na no worries, I don't want to cite multiple, thanks! One more quick follow-up: I tried to use it like this ` \citelinktext{Doe2019}{Doe, \fullciteyear{Doe2019}}` which doesn't work because of Nested citation command.. Is there a way to allow this kind of citation? :)
    – Highnoon
    Nov 7, 2023 at 9:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .