0

I have a bigger template which includes biblatex

\RequirePackage[backend=biber,
        style=ieee,
        citestyle=numeric-comp,
        sortcites,
        url=true,
        doi=false,
        defernumbers
        ]{biblatex}[2012/08/17]

I use TeXstudio where I set the Default Bibliography Tool to biber. Furthermore, I add the bibliography file via the command \addbibresource{bibliography.bib}. The bib-file is in the same folder as the tex-file. Sadly, the bibliography isn't recognised. I get a warning No file main.bbl. but that's it. I also can't see, that a biber and BibLaTex runs at all.

When I add the bibliography via \bibliography{bibliography} everything works fine. Do you have any hints for me what I'm doing wrong?

Content of the bibliography.bib file (just one dummy entry):

@article{dummy1,
    title = {dummytitle},
    pages = {},
    author = {Doe, John},
    langid = {english},
}
  • I suppose the correct command for your setup would be \printbibliography instead of \bibliography{bibliography} – Robert Seifert Feb 13 '21 at 14:02
  • No, that's something totally different. \printbibliography just prints the bibliography. I'm struggling with importing the bib data as is (hence, the .bib file). – Steradiant Feb 13 '21 at 14:06
  • But how do you suppose that is the issue? What does the .blg Log-File say? Do you actually \cite anything? The command bibliography is not correct for biblatex using the biber backend, \printbibliography is. Have a look here. If that does not help we will need a minimal executable example to reproduce your problem. PS: Have you tried to run biber manually (texstudio -> tools -> bibliography)? – Robert Seifert Feb 13 '21 at 14:12
  • 1
    show the log-file and the blg-file (if there is one). – Ulrike Fischer Feb 13 '21 at 14:19
  • 1
    Basically \bibliography and \addbibresource are defined using the same underlying helper macros, so I would be very surprised if one worked and the other didn't on the LaTeX side. I can, however, imagine your editor only being able to deal with one of the two when it comes to say, .bib file detection, auto-completion and auto-Biber/BibTeX-run features. But you would have to share with us exactly what you tried, what happened and how it did not work for you. (How exactly do you compile your document? What do your editor's compile settings look like?) – moewe Feb 13 '21 at 14:33
  • I added the content of the bibliography.bib file. There is no .blg log-file, that's exactly the thing. It seems, that the bib isn't recognized at all. – Steradiant Feb 13 '21 at 14:33
  • @thewaywewalk Technically, \bibliography is correct if you use biblatex. It is just deprecated and \addbibresource is recommended instead. Note that this holds independent of the backend (Biber or BibTeX) you use as long as we are talking about biblatex. – moewe Feb 13 '21 at 14:39
  • I know that the two commands are the very similar but because \bibliography is deprecated I want to use \addbibresource. Running biber manually seemed to help (texstudio -> tools -> bibliography). Nevertheless, I have to make two latex runs afterwards to have the numbers in line (otherwise all cites have the key [0]). Another thing is, that \cite doesn't suggest available citation keys. I tried to make a minimal example but everything works fine there. Hence, I must have to do with the provided template but it's too big (and I'm not allowed) to post it. – Steradiant Feb 13 '21 at 14:47
  • 1
    With the option defernumbers active it is expected that you need at least two LaTeX runs after the Biber run for the numbers to appear properly. Usually this shouldn't be much of an issue since you probably don't change your citations/bibliography in every run and the temporary files stick around with the relevant details. Whether or not Biber is run automatically and auto-completion of \cite and friends are features of your editor, not LaTeX. Especially if your biblatex declarations are hidden in separate files your editor might not be able to pick them up properly. – moewe Feb 13 '21 at 16:09
  • Thanks for the information. What's the advantage of using defernumbers? I'm wondering that TeXstudio handles everything correctly when using \bibliography hence, it automatically executes two runs and shows the auto-completion (even though the settings and declarations are hidden in separate files). – Steradiant Feb 14 '21 at 14:50
  • This solved the issue with the auto-completion of the \cite command: https://tex.stackexchange.com/a/262629/166503 – Steradiant Feb 14 '21 at 15:23
  • defernumbers is often useful if you have a numeric style and a split bibliography consisting of several or filtered \printbibliography calls. The option then tries to make the numbering in the bibliographies continuous. If you only have a single \printbibliography (which is not filtered) there usually is no point in using defernumbers. I'm guessing \bibliography works fine because your editor's auto detect feature always accepts \bibliography (as it is supported both with biblatex and BibTeX), but \addbibresource only works if your editor can tell you use biblatex. ... – moewe Feb 15 '21 at 21:22
  • ... Remember that your editor is not TeX: Its autocomplete features etc. are usually powered by some sort of RegExp document parsing, not by the actual code that would be executed during a TeX run. So loading biblatex in an external file not parsed by your editor for hints on your packages or loading the package in a way that confuses the parser might cause weird behaviour in your editor, while the TeX run works perfectly fine. – moewe Feb 15 '21 at 21:24

1 Answers1

1

On the LaTeX (or rather biblatex) side \addbibresource{<filename>.bib} and \bibliography{<filename>} do very similar things and are implemented in terms of the same auxiliary macros, so there should be no difference whether you use

\addbibresource{<filename>.bib}

or

\bibliography{<filename>}

The former is preferred over the latter, since it allows for additional options and \bibliography is only a legacy interface to support more BibTeX-like code.


The behaviour discussed in the comments is not due to LaTeX, it is purely related to features of your editor (auto-completion of entry keys in \cite commands, auto-running of Biber etc.). Editors usually have their own methods to understand TeX files, but usually this involves parsing the .tex input; it does not involve actually running TeX to see what happens.

Here it may indeed be the case that \bibliography works better than \addbibresource. Since \bibliography is a command defined by the LaTeX kernel, most editors will probably always try to pick it up. It is reasonable to only pick up a command like \addbibresource when the editor 'detects' that biblatex is being used. And that's where things can go wrong. If your editor fails to pick up that you are using biblatex it may not treat \addbibresource as expected. Of course if your editor has no support for biblatex at all, all bets are off.

Depending on your exact document structure, you might be able to help your editor to understand that you load biblatex by removing some line breaks in the biblatex calls (see e.g. https://tex.stackexchange.com/a/106755/35864). But if you load biblatex in a file that is later \input to your preamble or loaded with \usepackage, your editor's file parsing may simply not be able to detect biblatex (see e.g. https://tex.stackexchange.com/a/317858/35864). In that case some editors have a feature to manually declare that you use biblatex (e.g. TeXstudio lets you select .cwl files: https://tex.stackexchange.com/a/262629/35864).

moewe
  • 175,683