I'm working on a fairly vanilla (few additional packages), up-to-date installation of MiKTeX 2.9.6668 on Windows. At some point, I noticed that my source file includes two instances of the \bibliographystyle{...}
command. It's called once in the preamble, and once in the document body right before generating the actual bibliography using \bibliography{...}
.
After removing the first of the two calls, bibtex
no longer generated a .bbl
file, so the bibliography was missing from my document. Then, I found out that removing the other call also makes the bibliography no longer compile. The document will only contain the bibliography if both calls are present in the document, which seems redundant to me. In examples on where to use \bibliographystyle
, I have seen both options, but none of the sources I could find says that it needs to be present in both places.
I did use makebst
of the custom-bib
package to generate a custon bericht.bst
bibliography style. This style works fine and my bibliography looks as I expect it to, and it doesn't make a difference whether I use the custom style or plain
– the command still has to be there both times for the bibliography to appear.
My toolchain is running latex
-> bibtex
-> latex
-> latex
, and I'm using a standard BibTeX .bib
file (no biblatex
). The bibtex
logfile (.blg
) contains the following:
This is BibTeX, Version 0.99dThe top-level auxiliary file: bericht.aux
I found no \bibstyle command---while reading file bericht.aux
(There was 1 error message)
This error message is the same, regardless of which instance of \bibliographystyle
I remove.
The issue is not critical since everything works as I want it to as long as both calls are there. But why is that so?
Edit: It turns out that I didn't go far enough in narrowing down the problem. The cause is, of course, that I misunderstood and misapplied a command offered by a package, and that I was stupidly very confident that that one couldn't be related to the problem. Here is a reduced source that causes the issue; I will post the answer right after.
% !TX TS-program = pdfLaTeX+MakeIndex+BibTeX
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt,hidelinks]{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{a4paper}
\usepackage{cite}
\bibliographystyle{plain}
\usepackage{hyperref}
\usepackage{todonotes}
\usepackage{etoolbox}
\newtoggle{draft}
\toggletrue{draft}
\title{Article title}
\author{Author}
\begin{document}
\maketitle
\tableofcontents
\nocite{*}
\iftoggle{draft}{%
\listoftodos
}
% Commenting this out causes bibtex failure.
% \bibliographystyle{plain}
\bibliography{bericht}
\end{document}
\bibliographystyle
, the other one is\bibliography
. They are not the same command.\bibliographystyle
twice, and\bibliography
once. If I remove one of the two calls to\bibliographystyle
,bibtex
fails. I will prepare a minimal example that causes the issue and add it to the question.