Hacking BibTeX

I needed to use the Cambridge LaTeX style for books, which is very pretty and compact, but I wanted to produce PDF's where clicking on the title of articles or books would open a browser with that paper. See for example the blue text below, which links to the Physical Review A article

latex reference.png

This is a trick that I used in my own thesis, as well as with other people's thesis as well. The trick is very simple. In this case I copied the cambridgeauthordate.bst file into cambridgeauthordateurl.bst and enlarged the list of allowed fields to include URL

ENTRY
  { address
	author
	booktitle
	chapter
	edition
	editor
	howpublished
	institution
	journal
	key
	month
	note
	number
	organization
	pages
	publisher
	school
	series
	title
	type
	volume
	year
	URL
  }
  {}
  { label extra.label sort.label }

and then I edited the section that starts with FUNCTION { format.title … so that it read

FUNCTION {format.title}
{ title empty$
	{ "" }
	{ URL empty$
	  { title }
	  { "\href{" URL * "}{" * title * "}" * }
	  if$
	}
  if$
}

Save the file and include it with \bibliographystyle{cambridgeauthordateurl} Notice how the sixth line simply concatenates, using the postfix operator *, five different strings into the final text that forms the title.