Just as a preamble, I use MikTex 2.8, the latest TeXworks for Windows, the natbib, hyperref, and pdftex packages, JabRef to manage my citations, and the pdfLatex option in TeXworks for compilation.
Everything works correctly and as expected — unless I include the URL of an electronic paper I am citing. Then, compilation crashes, with the following error:
! Missing $ inserted.
<inserted text>
$
l.321 ....com/sol3/papers.cfm?abstract_id=1697352}
Here is the minimal example which generates this error:
\documentclass[12pt, letter]{article}
\usepackage[pdftex]{graphicx}
\usepackage{natbib}
\bibpunct{(}{)}{;}{a}{}{,}
\usepackage[pdftex,
urlcolor=rltblue, % \href{...}{...} external (URL)
filecolor=rltgreen, % \href{...} local file
linkcolor=rltred, % \ref{...} and \pageref{...}
citecolor=black,
colorlinks=true,
hypertexnames=false,
bookmarks=true,
bookmarksnumbered=true,
bookmarksopen=false]{hyperref}
\begin{document}
\pagestyle{plain}
Testing. \cite{Shor:2011all}
\bibliographystyle{apsr}
\bibliography{testurl}
\end{document}
The testurl.bib
file, includes the item in question this way:
@ELECTRONIC{Shor:2011all,
author = {Boris Shor},
year = {2011},
title = {All Together Now: Putting Congress, State Legislatures, and Individuals
in a Common Ideological Space to Assess Representation at the Macro
and Micro Levels},
url = {http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1697352},
owner = {Boris},
timestamp = {2010.04.04}
}
As you can see, it references the url of the electronic document (unpublished paper) I am trying to cite from SSRN: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1697352
The generated .bbl file contains the following item:
\harvarditem{Shor}{2011}{Shor:2011all}
Shor, Boris. 2011.
\newblock ``All Together Now: Putting Congress, State Legislatures, and
Individuals in a Common Ideological Space to Assess Representation at the
Macro and Micro Levels.''.
\newline\harvardurl{http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1697352}
What's going wrong?
Best Answer
Since you use
hyperref
, you don't need to load theurl
package. After loadinghyperref
, you could redefine\harvardurl
:Orignally,
natbib
defines it byThis definition doesn't work with underscores in the argument.
\url
fixes it. If you would like to have italic urls, you could achieve that for example by