Problems with Natbib: strange URL format and urldate not shown

If you have in your code \bibliographystyle{plainnat} then the "URL" text comes from the style.

In the plainnat.bst file you can find the following code:

FUNCTION {format.url}
{ url empty$
   { "" }
   { new.block "URL \url{" url * "}" * }
   if$
}

The part "URL \url{" url * "}" * is responsible for your problem. You can delete URL at the start of it or change it in any way you like.

For the urldate (it is a little more complicated):

In the same plainnat.bst file for example under the code above add the following lines:

FUNCTION {format.urldate}
{ urldate empty$
   { "" }
   {new.block  "[Accessed on: " urldate * "]" * }
  if$
}

Save it and do a search in the same file for "url". In one place you will find:

ENTRY
{ address
author
........%some more functions
type
url
volume
year
}

Add urldate under url. Save it. Then do a search for format.url output and add under every single one format.urldate output.

For example by misc:

FUNCTION {misc}
{ output.bibitem
  format.authors output
  author format.key output
  title howpublished new.block.checkb
  format.title output
  howpublished new.block.checka
  howpublished output
  format.date output
  format.issn output
  format.url output
  note output
  format.urldate output     %places the "urldate" after the "note"
  new.block
  fin.entry
  empty.misc.check
}

So, the order of the different outputs (e.g. format.urldate output) in the different functions (e.g. misc) denotes also the order of their insertion in the references.

That is all :)


The url field should just contain the web address, no tex formatting around it. So in this case you should remove the command \url. Also, standard natbib styles do not provide a urldate field. Instead you can put the information in the note field:

Sample output

from

\documentclass{article}

\usepackage{url}
\usepackage[numbers]{natbib}

\begin{document}

Citing \cite{CornellUniversity.}

\bibliographystyle{plainnat}
\bibliography{refs}

\end{document}

with refs.bib containing

@misc{CornellUniversity.,
  author = {{Cornell University}},
  title = {{Benedict R. O'G. Anderson}},
  url = {http://www.cornell.edu/search/index.cfm?tab=people&netid=bra2&q=benedict%20anderson},
  note = {Last visited 2012-03-18}
}

As @Mico points out, extra braces around the title field prevent its case being changed by bibtex.

Tags:

Natbib

Urls