0

I see there are many styles for biblatex to generate the "keys" automatically in the bibliography, but I would like to use the actual cite key, so that I can completely customise it myself.

For instance if my entry is

@article{Th,
    Author = {Dude},
    Title = {thing}}

I would like that the text produced to be "this thing is said in [Th]" and I would like the reference to appear as:

[Th] Dude, thing

It seems so simple but cannot find what "style" this is. It seems to be the "abstract" style but biblatex tells me "style abstract not found".

Edit: the reason why I use biblatex is because I need two separate bibliographies based on some keyword, so if someone knows a way to do that with traditional bibtex (whatever that means), I'll take it!

| improve this question | | | | |
4

Naively, I would have thought that

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{entrykey}
  }
}

should work for an alphabetic base style (and would be one of the most idiomatic solutions). That does not seem to be the case for Biber 2.12, so I opened https://github.com/plk/biber/issues/259 at the Biber bug tracker.

edit As PLK answered

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{citekey}
  }
}

citekey instead of entrykey works. In the Biber versions from 2.13 onwards entrykey is also accepted.


In the meantime here is a work-around that copies the entrykey to the shorthand field. Since the alphabetic style uses the shorthand field as an 'override' for the label, copying the entrykey to that field will cause the entrykey to be the label. The mapping will not overwrite an existing shorthand. If you want that you can add [overwrite=true] to the \map directive. You can read more about source maps in the biblatex documentation, §4.5.3 Dynamic Modification of Data (pp. 182-193). Essentially source maps allow you to manipulate the contents of fields of .bib entries dynamically from the .tex source.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

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

\addbibresource{biblatex-examples.bib}

\DeclareSourcemap{
  \maps{
    \map{
      \step[fieldsource=entrykey]
      \step[fieldset=shorthand, origfieldval]
    }
  }
}


\begin{document}
\cite{sigfridsson,worman,geer}
\printbibliography
\end{document}

Bibliography with entrykeys as label

Note that this kind of label generation goes a bit against the idea of biblatex (and BibTeX). Usually most labels should be generated by Biber/BibTeX automatically and only occasionally you may want to overrule something with shorthand. Note that biblatex's label creation is fully customisable, so if you can state your desired labels in algorithmic terms that biblatex understands, that would be the preferred solution. The entry keys should really be purely internal.


The abstract style you refer to in the question is presumably the BibTeX style abstract.bst. BibTeX's .bst styles are completely incompatible with biblatex and can not be used with that package. The biblatex styles debug and draft might also be interesting, though they should usually not be used in normal documents and their output is probably less suitable for what you have in mind.

| improve this answer | | | | |
  • Thanks for the answer, I guess I will look for something more simple as usually, when I add something complex that I don't understand, later that generates errors that I don't understand and I lose tons of time. Also, the reason why I use biblatex is because I need two separate bibliographies based on some keyword, so if someone knows a way to do that with traditional bibtex (whatever that means), I'll take it! – kaleidoscop Mar 27 '19 at 18:26
  • @kaleidoscop There are other possible ways to achieve a similar effect, but I believe that this method is one of the more natural/idiomatic solutions. I'll add some explanatory words. If there is still something left unclear, please don't hesitate to ask. Don't take the final bit of the answer as an attempt to dissuade you to use biblatex. There are ways to separate bibliographies with BibTeX, but with biblatex that is usually much easier to pull off. – moewe Mar 27 '19 at 19:14
  • I tried and it does not work, it leaves the alphabetic style. I actually replaced "biber" with "bibtex8" because I wanted to avoid installing something else. Is it the reason why it failed? – kaleidoscop Mar 28 '19 at 8:24
  • @kaleidoscop Yes, you must use Biber for \DeclareSourcemap to work. – moewe Mar 28 '19 at 8:24
  • One of the problem is for names that are two fold, such as "Jonhson-Smith", the alphabetic style naturally writes [JS] when I would like ieally [Js]. Do you think I could customise in this way? – kaleidoscop Mar 28 '19 at 8:26
1

This is already supported via the pseudo-key citekey:

\DeclareLabelalphaTemplate{
  \labelelement{
    \field[final]{citekey}
  }
}

I will probably add entrykey as an alias for compatibility with sourcemaps in the next version.

| improve this answer | | | | |
  • Ugh ... I should really start reading the documentation. For people like me the alias entrykey would be great. – moewe Mar 28 '19 at 22:05

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.