7

What exactly does \addbibresource do that \bibliography does not? I am aware of the advantages mentioned here which concern, for example, the use of an optional argument and the possibility of specifying remote resources. However, nothing I've come across to date really explains the following.

The manual for biblatex explains a useful-sounding feature for users who want to change their citation keys without breaking existing documents:

ids field (comma-separated list of entrykeys)

Citation key aliases for the main citation key. An entry may be cited by any of its aliases and biblatex will treat the citation as if it had used the primary citation key. This is to aid users who change their citation keys but have legacy documents which use older keys for the same entry. This field is consumed by the backend processing and does not appear in the .bbl.

I took this to mean that adding an ids field containing the old key to a renamed entry in my .bib file would enable me to cite the entry with either the old key or the new one.

However, I could not get this to work. Here is a minimal example showing the problem.

\documentclass{article}

\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
  \bibliography{my}

\begin{filecontents}{my.bib}
    @article{somebody-sgt,
      ids       =   {someone-sgt},
      author    =   {Somebody, Someone},
      title     =   {Some Great Title},
      journal   =   {Best Journal},
      year      =   3019,
      pages     =   {32--39},
      volume    =   3,
      number    =   4}
\end{filecontents}

\begin{document}

Here is some text with a citation \autocite{somebody-sgt}. Here is some more text using the old key \autocite{someone-sgt}.

\printbibliography

\end{document}

When I run this through pdflatex, biber, pdflatex, pdflatex, I get the following error message in the output:

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                question
(biblatex)                and rerun LaTeX afterwards.

Rerunning the compilation sequence makes no difference to either error or output:

wrongful output

I periodically returned to this problem but I just could not figure out any way to make it work. Nor could I figure out any plausible reading of the manual which would suggest the feature was designed to do something completely different.

This has bugged me for a long time. So much so that I decided to ask this question. However, it turns out that unlike my initial code, the following code works as I'd expected:

\documentclass{article}

\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
  \addbibresource{my.bib}

\begin{filecontents}{my.bib}
    @article{somebody-sgt,
      ids       =   {someone-sgt},
      author    =   {Somebody, Someone},
      title     =   {Some Great Title},
      journal   =   {Best Journal},
      year      =   3019,
      pages     =   {32--39},
      volume    =   3,
      number    =   4}
\end{filecontents}

\begin{document}

Here is some text with a citation \autocite{somebody-sgt}. Here is some more text using the old key \autocite{someone-sgt}.

\printbibliography

\end{document}

which produces:

rightful output

So now I'm curious. The documentation mentions no specific requirements for using ids that I can find excepting the requirement to use biber. However, it seems to require \addbibresource. But, in that case, more is going on than is indicated in the answer to the question I referenced above. This is not a remote database, no optional argument is required. Really, the set up could not be much simpler.

I am also hoping that I may learn why \addbibresource has to be so much more annoying to use than bibliography! This is basically why I have continued to use the latter - everything I'd read suggested the advantages of the former were not ones I currently had any use for, so the ease of using the latter trumped. I have a complex set up which involves loading quite a number of .bib files. This means that specifying them one at a time would be quite a pain. (I've not yet decided if it is worth the benefit of getting the ids feature to work.)

cfr
  • 198,882
  • 2
    I think we'll need to see some logs here. For me, both of you examples give the same result, with both references correct but that (misleading) log warning, provided I start with a clean directory when changing from one to the other. What I do find is that running pdflatex, biber, pdflatex (all 'good'), biber, pdflatex does give one undefined citation, i.e. things are not 'stable' irrespective of the choice of \bibliography/\addbibresource. That pattern repeats: I suspect a bug. – Joseph Wright Feb 02 '14 at 07:56
  • 2
    Also, if you look at the code then \bibliography is just a wrapper around the same internals as \addbibresource, and there is no reason to expect differences in fundamental behaviour. – Joseph Wright Feb 02 '14 at 07:58
  • There seems to be a bug with these key aliases, as they do not appear to stabilise. I found this behaviour with \bibliography as well as \addbibresource (as Joseph Wright says: internally, \bibliography is really just a trimmed-down version of \addbibresource). – moewe Feb 02 '14 at 13:07
  • I don't think that it is intended to use both keys in the same document. Depending on which key is used first you get an entry \entry{somebody-sgt}{article} or \entry{someone-sgt}{article} in the bbl but you don't get both (which would probably lead to dublicates in the bibliography). – Ulrike Fischer Feb 02 '14 at 15:42
  • @UlrikeFischer I often see this problem with documents which contain only the old key. (In fact, that's typically the case - if I'm writing a new document, I use the new key.) I just included both in the example for comparison. I tried changing the new key to the old key in the minimal example, clearing all generated files and recompiling. In that case, I do get the right result on the first run, despite the warning, but I get the error if I rerun the compilation sequence. And people are right, \bibliography versus \addbibresource makes no difference. – cfr Feb 02 '14 at 16:00
  • @JosephWright Which log files would be useful? – cfr Feb 02 '14 at 16:04
  • @cfr Forget about that idea: as we all seem to find, this issue pops up with the latest release but is not dependent on \addbibresource. Could you report to the GitHub bug tracker? – Joseph Wright Feb 02 '14 at 16:07
  • @JosephWright Will do. By the way, I can read chat but I can't post there. (Similar to Meta - the system doesn't recognise me as logged in etc.) – cfr Feb 02 '14 at 16:18
  • 1
    This is a bug. I'm looking into it. – PLK Feb 02 '14 at 16:31
  • Just reported the issue at https://github.com/plk/biblatex/issues/201 as requested by JosephWright. Apologies to @PLK - your comment must have been posted while I was preparing the bug report. – cfr Feb 02 '14 at 16:57
  • That's fine - I'd rather have a bug report to track it anyway. – PLK Feb 02 '14 at 16:59
  • @cfr: I think you are right. I had overlooked the \keyalias{someone-sgt}{somebody-sgt} in bbl, and it is disappearing and reappearing with every biber run. – Ulrike Fischer Feb 02 '14 at 17:15
  • This should be fixed in the biblatex 2.9 DEV version on SF (you need to be using biber 1.9 DEV too) – PLK Feb 03 '14 at 20:19
  • @PLK Fantastic. I guess this will make it into TeX Live in good time? (I'm not sure what's needed to compile biber.) – cfr Feb 03 '14 at 22:24
  • You don't have to compile - you can just pull the 1.9 binary from SF and drop it over your existing one. The fix only changed biblatex. It'll be in TL probably in Feb but it would be good if you could test it now and close the github case. – PLK Feb 04 '14 at 12:26
  • Oh, OK. Right. Will do, then. I can't do it right now but I will try it asap. Probably I'll drop it elsewhere rather than overwriting the existing one. – cfr Feb 04 '14 at 17:12
  • 5
    This question appears to be off-topic because it is about a bug in the software (biblatex/biber), that was fixed by the developers, see https://github.com/plk/biblatex/issues/201. – moewe Feb 14 '14 at 09:01
  • Just to note that I tested the fix as noted in the bug report and confirmed that it does, indeed, resolve the bug. It might be useful for this question to stay around until the fixed versions of biblatex and biber make it into TL, for example. But I don't know what the policy is on this. – cfr Feb 14 '14 at 18:18

0 Answers0