Suppose I have a .Bib file with an entry like this:

author = {Shakespeare, William},
bookauthor = {Shakespeare, William},
maintitle = {Collected Works},
booktitle = {Tragedies},
title = {King Lear},
volume = {1},
pages = {53-159},

Important: it could be any other reference, because I'll deal with different Bib files with only one reference each one - they will be generated automatically by another program.

I'm using Biblatex inside Overvleaf platform.

My question is: Is it possible to retrieve the entryfield (that in the example above is the string lear) and use it to be passed as a parameter?



Where var_entrykey content must be lear (refering to the example above) or whatever other entry depending the bib file I'll be using (remembering that all the Bib files will have only one reference).

The problem is that I don't know how to read the entrykey automatically, i.e. usually we need to know the entrykey to reference it, that's the normal use and obvious. But in this case, I need a hack to retrieve it - and put it in a variable - without knowing it's content beforehand.

Warm regards

1 Answer 1


The following only works reliably if you cite exactly one entry in your document. Otherwise there is no way of knowing whose entry key you want. This can be ensured by citing only one entry with \cite or \nocite, in which case you'd have to know the entry key, so the whole thing here would be pointless, or by making sure that your .bib file only contains a single entry.

We can use \AtDataInput to hook into the code that reads the entries from the .bbl file. At that point we can save the entry key of the entry that is currently being processed in a variable. If we know there is only going to be one entry in the document, this gives us the entry key we want. (If there were several entries in the bibliography, those calls would overwrite each other and we would end up with the last entry key in our variable. With a wee bit of work we could obtain only the first entry key. Other tricks could be used as well to determine which key to take, but we'd have to have a way to single out one entry.)


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



  author     = {Shakespeare, William},
  bookauthor = {Shakespeare, William},
  maintitle  = {Collected Works},
  booktitle  = {Tragedies},
  title      = {King Lear},
  volume     = {1},
  pages      = {53-159},


Entry key \theoneentrykey



Entry key lear//macro:->lear

  • Thank you so much @moewe
    – Britto
    Commented Feb 7, 2021 at 12:30

You must log in to answer this question.

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