3

I'm working on a LaTeX document on Overleaf, with a bibliography in a .bib file. Throughout the document, I'm using \cite{key} to get a numeric link to the bibliography and do not want to change that behavior.

I want to be able to refer to a bibliographic entry in specific instances in a way that allows me to use a custom text string. For example:

This will be bring me to the right bibliography entry \cite{key}
And I want this to also bring me to the right bibliography entry \hyperref[key]{Custom Text}

So far I've tried \autoref and \hyperref, but, simply put, I don't know how to link to bibliographic items like I could with sections, tables, or figures.

As of right now, my code looks like so:

\documentclass[10pt]{iopart}
\usepackage{hyperref}
\usepackage{cite}
\begin{document}

Text that is cited \cite{SomeKey}

\bibliographystyle{IEEEtran}
\bibliography{litreview.bib}
\end{document}

litreview.bib has a bunch of entries formatted as such:

@article{SomeKey,
  title={Title},
  author={Author},
  journal={Journal},
  year={Year},
  publisher={Publisher}
}

The output looks like:

Text that is cited [1]

I want to, somewhere else in the paper, be able to \href or \hyperref to the same spot that \cite brings me to, but with my own text rather than [1].

Is there a way to link to a specific entry of the bibliography with custom text?

7
  • 1
    The question is tagged with both biblatex and BibTeX. Solutions for biblatex will be very different from solutions for classical BibTeX. It would help a lot if you could tell us more about your bibliography and citation setup. Ideally you would share a small example document that reproduces the status quo w.r.t. citations and the bibliography with as little unrelated code as possible,
    – moewe
    Commented Jan 30, 2022 at 5:54
  • Thanks so much! I honestly don't know the difference, but I've added some more details? Hopefully that should help? I'm not sure which one I'm using, but it's probably Overleaf's default? Commented Jan 30, 2022 at 6:39
  • To help fix ideas, please provide an example of "my own text rather than [1]".
    – Mico
    Commented Jan 30, 2022 at 6:55
  • The code shown in the question is not really the small example document I had in mind (I imagined something starting with \documentclass and containing \begin{document}...\end{document}) that can be compiled directly without further modifications (what is sometimes called an MWE: tex.meta.stackexchange.com/q/228/35864). But the code shows clearly that you are not using biblatex, so I will remove that tag to avoid confusion.
    – moewe
    Commented Jan 30, 2022 at 7:00
  • 1
    Note that technically speaking, the argument of \bibliography is the base name of the .bib file (i.e. the file name without extension). So \bibliography{litreview.bib} is wrong and should be \bibliography{litreview}. (Most modern systems will work just fine if you wrongly include the .bib extension here, but it is still a good idea to get rid of it.)
    – moewe
    Commented Jan 30, 2022 at 7:01

1 Answer 1

5

Assuming you load hyperref (and an otherwise standard setup) you can use that hyperref sets link targets to all bibliography entries. These targets can be accessed as cite.<entrykey> with \hyperlink[cite.<entrykey>]{<link text>}.

In order to get the same link colour as normal citations, we have to resort to internal commands and end up with the following.

\documentclass{article}
\usepackage{hyperref}

\makeatletter
\newcommand*{\citelinktext}[2]{%
  \hyper@@link[cite]{}{cite.#1}{#2}}
\makeatother

\begin{filecontents}{\jobname.bib}
@book{elk,
  author    = {Anne Elk},
  title     = {A Theory on Brontosauruses},
  year      = {1972},
  publisher = {Monthy \& Co.},
  location  = {London},
}
\end{filecontents}


\begin{document}
Lorem \cite{elk}

\citelinktext{elk}{foo}

\bibliographystyle{IEEEtran}
\bibliography{\jobname}
\end{document}

Arbitrary text with link to bib entry.

1
  • 1
    This worked PERFECTLY!!! Thanks you!!! Commented Jan 30, 2022 at 19:26

You must log in to answer this question.

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