BibTeX, biblatex and biberCan't get .bib file to work

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
KyuGreywolf
Posts: 3
Joined: Wed Apr 14, 2021 2:28 am

Can't get .bib file to work

Post by KyuGreywolf »

Greetings!

I've been using LaTeX for a while now, but never used .bib files for references. I always did them in Word, and then copied them in. Today I decided to try JabRef, and hence, try using .bib files. I can't however, get any working code at all, it's just a disaster. The following is a minimal example:

Code: Select all

\documentclass[a4paper,12pt]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[nottoc]{tocbibind}
\title{References}

\begin{document}
	\maketitle
	\tableofcontents
	\cite{b}
	\bibliographystyle{unsrt}
	\bibliography{References}
\end{document}
The reference is completely made up, I just want it to work. I think the main warning is, 'Empty `thebibliography' environment'.

Any help would be appreciated, thanks! (-:
Attachments
References.bib
(161 Bytes) Downloaded 409 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Can't get .bib file to work

Post by Ijon Tichy »

Here the same as Infominimal working example, so that Run LaTeX here can process the file:

Code: Select all

\begin{filecontents}[force]{\jobname.bib}
% Encoding: UTF-8

@Article{b,
  author  = {de},
  journal = {v},
  title   = {fr},
  year    = {2001},
}

@Comment{jabref-meta: databaseType:bibtex;}
\end{filecontents}
\documentclass[a4paper,12pt]{article}

\usepackage[english]{babel}
%\usepackage[utf8]{inputenc}% Not needed any longer for LaTeX since 2018-04-01.
\usepackage[nottoc]{tocbibind}
\title{References}

\begin{document}
	\maketitle
	\tableofcontents
	\cite{b}
	\bibliographystyle{unsrt}
	\bibliography{\jobname}
\end{document}
As you can see, it works. So you've done something wrong on your side. Have you done the needed runs:
  1. PDFLaTeX
  2. BibTeX
  3. PDFLaTeX
  4. PDFLaTeX
If so, can you show us the blg-file?

BTW: You are using BibTeX. BibTeX cannot handle UTF-8, but only US-ASCII. So you should not export the bib-file with UTF-8 encoding! You could use UTF-8, if you would use biblatex + biber:

Code: Select all

\begin{filecontents}[force]{\jobname.bib}
% Encoding: UTF-8

@Article{b,
  author  = {de},
  journal = {v},
  title   = {fr},
  year    = {2001},
}

@Comment{jabref-meta: databaseType:bibtex;}
\end{filecontents}
\documentclass[a4paper,12pt]{article}

\usepackage[english]{babel}
\usepackage[nottoc]{tocbibind}
\usepackage{csquotes}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\title{References}

\begin{document}
	\maketitle
	\tableofcontents
	\cite{b}
	\printbibliography
\end{document}
Note: In this case you have to configure your editor to use biber instead of bibtex!

I always recommend to use biblatex + biber unless the production process (e.g. the publisher) does not support it.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
KyuGreywolf
Posts: 3
Joined: Wed Apr 14, 2021 2:28 am

Can't get .bib file to work

Post by KyuGreywolf »

Greetings! Thanks for your reply my friend, it was super helpful!

I managed to get the second example you gave working, with biblatex + biber. I'm using TeXstudio, so had to change the default bibliography setting in the configuration to biber. Thanks again :)
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Can't get .bib file to work

Post by Bartman »

@KyuGreywolf

Maybe a bit off topic:

As you can see from the entry that was not made in the table of contents, biblatex does not interface with tocbibind. It has its own options to control the insertion of the bibliography heading into the mentioned directory.
KyuGreywolf
Posts: 3
Joined: Wed Apr 14, 2021 2:28 am

Can't get .bib file to work

Post by KyuGreywolf »

Bartman wrote:@KyuGreywolf

Maybe a bit off topic:

As you can see from the entry that was not made in the table of contents, biblatex does not interface with tocbibind. It has its own options to control the insertion of the bibliography heading into the mentioned directory.
It's good that you've mentioned this, because this all stemmed from the issue of both having a Bibliography and References in the same document. I've managed to fix this using the line:

Code: Select all

\printbibliography[heading=bibintoc,title={Bibliography}]
And putting the References title in its own section
Post Reply