9

I have a strange problem with natbib. This code

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

creates the following output:

Cornell University. Benedict R. O’G. Anderson. URL http://www.cornell.edu/search/index.cfm?tab=people&netid=bra2&q=benedict%20anderson.

where:

1) The text "URL" is placed in front of the actual url

2) the url is not formated as a hyperlink (the url package is included)

3) the "urldate" property doesn't show up at all

How do I best solve those issues?

mort
  • 1,671
  • 1
    The formatting of bibliographic entries -- including the insertion of the string "URL" ahead of the actual url - is not controlled by the natbib package, but by the bibliography style you employ. The bibliography style also determines what may (or may not) be done with fields such as urldate. In short: Which bibliography style do you use? – Mico Mar 18 '13 at 18:05

2 Answers2

12

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 :)

Sonia
  • 261
5

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.

Andrew Swann
  • 95,762