BibTeX, biblatex and biber.bst file help - printing out urldate in the right place

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
nebjamin
Posts: 3
Joined: Thu Mar 26, 2015 11:56 am

.bst file help - printing out urldate in the right place

Post by nebjamin »

Hi All,

I have a custom .bst which I made a few years ago that supports Harvard referencing.

It's pretty much perfect, except for one thing.

I use Mendeley to create by .bib file, and for online sources this automatically captures the 'Accessed on' date. I have tinkered with the .bst file to get it to output this date correctly and it's nearly working, but I can't get the format correct without breaking the .bst format.

I am aiming for a reference like this:

The Economist (2011). Rolls-Royce: Per ardua | The Economist. URL
http://www.economist.com/node/18073351. [Online] (Accessed: 2014-
12-18).


Here is the section in my .bst file that outputs the date:

Code: Select all

FUNCTION {format.urldate}
{
  urldate
  duplicate$ empty$
    { pop$ "" }
     { " [Online] (Accessed: " * urldate * ")" * }
  if$
}
This makes the date come out twice (obviously):

The Economist (2011). Rolls-Royce: Per ardua | The Economist. URL
http://www.economist.com/node/18073351. 2014-12-18 [Online] (Accessed: 2014-12-18).

If I remove the first urldate from the .bst format.urldate function, I just get loads of errors. Not managed to find a decent reference for the .bst syntax language anywhere so going round in circles a bit and dissertation deadline is approaching.

How can I output just one date in the format required?

Thanks a lot,
Ben

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

.bst file help - printing out urldate in the right place

Post by Johannes_B »

Hi and welcome,

the old system with bst files to define the style of the bibliography is nearly dead since the modern biblatex came along with its good friend biber, a modern replacement for BibTeX.

Fixing stuff is always time consuming, it would be nice if you could prepare a testing case (minimal working example) and make your bst-file available for real on-case testing.


I think all new bst files provided by natbib support urls and accessed-on fields, they might be a good starting point to look at.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
nebjamin
Posts: 3
Joined: Thu Mar 26, 2015 11:56 am

Re: .bst file help - printing out urldate in the right place

Post by nebjamin »

Hi Johannes,

I appreciate that this may be a bit old now, but it is 99% perfect for what I need and my course will be finished in September. I feel like this must be a simple 1-liner fix, so would be great to get this sorted with my current setup if possible. Need all the time I can get to focus on creating the content!

I prepared a minimum working example. Has only what you need, attached.

Thanks everyone!
Ben
Attachments
latex.zip
(7.06 KiB) Downloaded 242 times
nebjamin
Posts: 3
Joined: Thu Mar 26, 2015 11:56 am

.bst file help - printing out urldate in the right place

Post by nebjamin »

Actually, after more googling I found the tamethebeast BibTeX guide and managed to solve my own problem.

In case it's useful to anyone else, the solution was a missing

Code: Select all

swap$
My urldate function now looks like:

Code: Select all

FUNCTION {format.urldate}
{
  urldate
  duplicate$ empty$
    { pop$ "" }
     { "[Online] (Accessed " swap$ * ")" * }
  if$
}
Thanks for the response in any case. The attached .bst file with the fix above makes pretty perfect Harvard style references.
Post Reply