[Tex/LaTex] Bibtex references not compiling because of LastPage package

bibtexerrorslastpagexetex

I am trying to compile an essay and it has references in it. I am using BibTeX and XeLaTeX. Here are the last few lines of the log

LaTeX Warning: Reference `LastPage' on page 4 undefined on input line 46.

[4] (./Essay.bbl (/usr/local/texlive/2011/texmf-dist/tex/latex/euenc/eu1lmtt.fd
)
Overfull \hbox (86.4996pt too wide) in paragraph at lines 9--13
\EU1/lmtt/m/n/12 http://goscandinavia.about.com/od/scandinaviatripplanning/p/sc
andnordic.htm\EU1/TimesNewRoman(0)/m/n/12 .

Overfull \hbox (66.03194pt too wide) in paragraph at lines 26--29
[]\EU1/TimesNewRoman(0)/m/n/12 Meltdown, October 2011.  URL \EU1/lmtt/m/n/12 ht
tp://english.aljazeera.net/programmes/meltdown/\EU1/TimesNewRoman(0)/m/n/12 .

LaTeX Warning: Reference `LastPage' on page 5 undefined on input line 29.

[5]
! Missing $ inserted.
<inserted text> 
                $
l.43 .../files/1892_the_nordic_model_complete.pdf}
                                                  .
? 

The commands entered are the following:

xelatex Essay.tex
bibtex Essay.aux
xelatex Essay.Tex
then the error

Here is a minimal working example:

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{natbib}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{setspace}
\pagestyle{fancy}
% clear any old style settings
\fancyhead{}
\fancyfoot{}
%new settings
\lhead{\footnotesize {Sebastian Stephenson}}
\rhead{\footnotesize{2812193}}
\rfoot{{\thepage} of \pageref{LastPage}}
%for hardvard style citation 
\citestyle{agms}
% addfont Times New Roman
\setmainfont{Times New Roman}
\begin{document}

\begin{doublespacing}
    \title{The Nordic Region and The Great Recession}
    %to remove the date that is added when it gets complied
    \date{}
    \maketitle
    %Because the maketitle command has been used, it automatically
    %issues \thispagestyle{plain} which overrides the fancy headings for
    %this page.  Must now tell Latex to override this
    \thispagestyle{fancy}
    With an understanding of what makes the Nordic region distinct from other regions. We will look at how the Nordic region is doing in the Great Recession. "The outlook for these countries is good" says Christian Ketal, economist at Harvard Business School and the Stockholm School of Economics "They are going to return...there own banking crises before the Great Recession,showing experience in managing a situation like today. It appears that the Nordic region is set for bright future.
\end{doublespacing}
    \bibliographystyle{plainnat}
    \bibliography{References} 
    \end{document}

Here is a sample of how I am citing in the Tex file.

the Nordic embassy.\citep{monoembassy} There is even consideration for further integration with one historian proposing a Nordic federation.\citep{econorfed} They are not completely homogenous societies. For instance Finland is the only Nordic country in the euro,\citep{econorfed} Norway is a oil powered economy\citep{unischobooklet5} and the last 30 years of Iceland.

Here are two samples of BibTeX entries:

 @article{nordicdecline,
author={Johan Carlstrom},
editor={Chris Kirkham},
title={Nordic Countries Plunge Into Recession as Export Markets Fail  - Bloomberg},
month={Febuary},
year={2008},
url={http://www.bloomberg.com/apps/news?pid=newsarchive&sid=at0pmFF3uEOY},
publisher={Bloomberg},
address={New York},
note={[14102011]}
}

@book{nordicpdfintro,
author={Torben M. Andersen and Bengt Holmström and Seppo Honkapohja and Sixten Korkman and Hans Tson Söderström and Juhana Vartiainen},
booktitle={The Nordic Model:Embracing globalization and sharing risks},
pages={13},
year={2007},
url={http://www.etla.fi/files/1892_the_nordic_model_complete.pdf},
publisher={Taloustieto Oy},
address={Helsinki,}
}

Can anyone explain what I need to do?

Note: The last BibTeX entry could be the issue.

Best Answer

You need to load a package to handle URLs, as the 'fall back' dimply does nothing, meaning that TeX tries to use _ in text mode then complains. The easiest way to do this is to load the url package

\documentclass{article}
\begin{filecontents}{References.bib}
 @article{nordicdecline,
author={Johan Carlstrom},
editor={Chris Kirkham},
title={Nordic Countries Plunge Into Recession as Export Markets Fail  - Bloomberg},
month={Febuary},
year={2008},
url={http://www.bloomberg.com/apps/news?pid=newsarchive&sid=at0pmFF3uEOY},
publisher={Bloomberg},
address={New York},
note={[14102011]}
}
\end{filecontents}
\usepackage{natbib}
\usepackage{url}
\begin{document}

the Nordic embassy.\citep{nordicpdfintro} 
\bibliographystyle{plainnat}
\bibliography{References} 
\end{document}

(Note: I've cut down to a minimal example, which has nothing to do with XeTeX. I've also used the filecontents environment to auto-generate a suitable .bib file as part of the LaTeX run. The later can be removed for a real document: it's just there to make the example work properly.)