3

When running this sample code:

\documentclass[11pt,a4paper]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[onehalfspacing]{setspace}
\usepackage{natbib}

\begin{document}

Hello World \cite{greenwood_theoretical_2016}

\end{document}

\bibliography{Bibliography}
\bibliographystyle{plain}

I keep getting the warning:

'Citation greenwood_theoretical_2016 on page 1 undefined on input line 10'

and the references are marked as '?' in the document.

I am using Sublime Text 3.2 with LaTeXTools on macOS High Sierra.
The builder is set to 'basic' so it runs:

pdflatex
bibtex
pdflatex
pdflatex

I exported my bibliography from Zotero (Format: Bibtex; Encoding: UTF-8) and checked the 'Bibliography.bib' file (which is in the same directory) and the citations seem to be correct (example):

@article{greenwood_theoretical_2016,
title = {Theoretical, contemporary observational and palaeo-perspectives on ice sheet hydrology: {Processes} and products},
volume = {155},
issn = {0012-8252},
shorttitle = {Theoretical, contemporary observational and palaeo-perspectives on ice sheet hydrology},
url = {http://www.sciencedirect.com/science/article/pii/S0012825216300095},
doi = {10.1016/j.earscirev.2016.01.010},
urldate = {2018-12-05},
journal = {Earth-Science Reviews},
author = {Greenwood, Sarah L. and Clason, Caroline C. and Helanow, Christian and Margold, Martin},
month = apr,
year = {2016},
keywords = {Geomorphology, Esker, Meltwater, Review, Hydrology, Channel, Glacier, Ice Sheet},
pages = {1--27}

Using biblatex instead of natbib gives me the reference's label in square brackets i.e.

Hello World [greenwood_theoretical_2016]

I also tried using different styles but nothing has changed.

I know there have been lots of questions about this, but nothing seems to work here.

New contributor
KingBoo is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 3
    Welcome to TeX.SX! – koleygr Mar 15 at 20:30
  • 1
    While it seems logical to specify \bibliographystyle before \bibliography, i don't believe it's required. This is mentioned in both answers below. (I'm unable to check; this laptop doesn't have latex installed, and all my reference books are inaccessible in boxes.) The real problem here is having the bibliography commands after \end{document}. – barbara beeton Mar 16 at 0:30
  • @barbarabeeton ... Yes, this is why I said in my answer that I am "almost sure" before think... because afterwards I thought that aux file (which will be used after bibtex) will already have the information of the style without need anything more... It is enough that is specified and will be used anyway from the aux file (since bibtex was another compilation). Thanks for the comment – koleygr Mar 16 at 23:38
3

In your given code are some issues:

  1. The order of calling \bibliographystyle and \bibliography should be changed in your code (style first!).
  2. With loading natbib you should better use style plainnat instead plain
  3. You have \end{document} before you calls the bibliography. That means the code after \end{document} is not executed.

Please use the following code:

\RequirePackage{filecontents}
\begin{filecontents*}{Bibliography.bib}
@article{greenwood_theoretical_2016,
  title = {Theoretical, contemporary observational and palaeo-perspectives 
           on ice sheet hydrology: {Processes} and products},
  volume = {155},
  issn = {0012-8252},
  shorttitle = {Theoretical, contemporary observational and 
  palaeo-perspectives on ice sheet hydrology},
  url = {http://www.sciencedirect.com/science/article/pii/S0012825216300095},
  doi = {10.1016/j.earscirev.2016.01.010},
  urldate = {2018-12-05},
  journal = {Earth-Science Reviews},
  author = {Greenwood, Sarah L. and Clason, Caroline C. and Helanow, 
            Christian and Margold, Martin},
  month = apr,
  year = {2016},
  keywords = {Geomorphology, Esker, Meltwater, Review, Hydrology, 
              Channel, Glacier, Ice Sheet, Read Level 3},
  pages = {1--27},
}
\end{filecontents*}


\documentclass[11pt,a4paper]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[onehalfspacing]{setspace}

\usepackage{natbib}


\begin{document}

Hello World \cite{greenwood_theoretical_2016}

\bibliographystyle{plainnat} % plain
\bibliography{Bibliography} % Bibliography

\end{document}

and see the expected result:

result with bibtex

If you want to get the bibliography numbered add option numbers to natbib:

\usepackage[numbers]{natbib}

The correct code to compile with biblatex is

\documentclass[11pt,a4paper]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[onehalfspacing]{setspace}

\usepackage{csquotes}
\usepackage[%
  natbib=true, % <=======================================
  backend=biber, % <=====================================
]{biblatex}
\addbibresource{Bibliography.bib} % Bibliography <=======


\begin{document}

Hello World \cite{greenwood_theoretical_2016}

\printbibliography

\end{document}

with the result:

enter image description here

  • 2
    Thank you! Seems like I've been a bit too focused on other things to do the basics right. – KingBoo Mar 15 at 22:21
  • I've taken the liberty of editing your code to (a) insert the instruction \RequirePackage{filecontents} at the top and (b) affix .bib to the end of the argument of \addbibresource. – Mico Mar 15 at 22:30
  • The order of \bibliographystyle and \bibliography is in general not relevant. I tested two short examples in both orders and both compiled just fine. There is nothing in the documentation of BibTeX that suggests otherwise and a cursory look at the commented source also does not suggest that the order is relevant. Of course points 2 and 3 are very valid. (See also barbara's comment under the question.) – moewe Mar 16 at 7:50
4

The part of the original answer here that says "I am almost sure that the command \bibliographystyle{plain} should be before the command \bibliography{Bibliography}" is not really correct because the bibtex compilation will be done separately and thus just the aux file will be used that already have the information about the bibiography style. (Thanks @barbarabeeton and @moewe...) Of course, the programming habits, will still make more people to add it before the print command since the code will be more human readable by saying "Get a style and print it" ... than "Print it... Ah! and don't forget... I need it in this style!" :P

Not tested but I am almost sure that the command \bibliographystyle{plain} should be before the command \bibliography{Bibliography} and most important (that here I am sure), that both commands should be before of the \end{document} command.

Please try it and answer if it is ok.

  • 1
    It worked! Thank you for your answer! – KingBoo Mar 15 at 22:27
  • 1
    The order of \bibliographystyle and \bibliography should not matter. See my comment under Kurt's answer and also barbara's comment under the question. – moewe Mar 16 at 7:51

Your Answer

KingBoo is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.