I would like to change the URL output from:

URL: the html link


[Online]URL: [Accessed on]

I am using:


Here I have explained the step by step to modify another bst from the harvard bundle; please refer to it for the step-by-step.

agsm.bst does not provide a urldate field, so you'd have to add by yourself to a modified bibtex style. I created the agsm-url.bst from the original agsm.bst and added a urldate field to it as in this answer. The diff:

>     urldate
<     { "\newline\harvardurl{" URL * "}" * write$ newline$ }
>     { "\newline\harvardurl{" URL * "}" * write$ newline$ 
>     urldate empty$
>       { skip$ }
>       { "[Accessed on: " urldate * "]" * write$ newline$ }
>       if$
>     }

If you don't want the linebreak before the URL block, just delete the \newline

Then I redefined the \harvardurl macro with

\renewcommand{\harvardurl}[1]{[Online] URL: \textit{#1}}

See this answer about redefining it to add hyperlinks with hyperref

Here's a MWE:

% Adapted bib file from tugboat.bib
    author = {Robert Welland},
    title = {{Editor's Comments}},
    journal = {TUGboat},
    volume = {1},
    number = {1},
    pages = {2--3},
    month = oct,
    year = {1980},
    ISSN = {0896-3207},
    urldate = {Fri Jul 13 10:24:20 MDT 2007},
    url = {http://www.math.utah.edu/pub/tex/bib/tugboat.bib}
    author = {Richard Palais},
    title = {{Message from the Chairman}},
    journal = {TUGboat},
    volume = {1},
    number = {1},
    pages = {3--7},
    month = oct,
    year = {1980},
% natbib.sty, line 1042:
\renewcommand{\harvardurl}[1]{[Online] URL: \textit{#1}}

And the output:

mwe sample

  • Thank you for your prompt response. However I am facing a problem because of the bst file. While I am tryinf to generate the bibtex I am having an error "pte=20, stack='20---the literal stack isnt empty for entry online while executing---line 1349 of file agsm-url.bst – Kerk Aug 23 '15 at 1:10
  • I tried so many alternatives by the same error keeps happening with the .bst file. I even tried the example file you posted as it is: ptr=2, stack= '20 0 ---the literal stack isn't empty for entry online while executing---line 1350 of file agsm-url.bst – Kerk Aug 23 '15 at 9:30
  • 1
    I just did it again here with no errors. What I've done is: 1. I copied the diff and put it in an agsm-url.diff file; 2. I copied the agsm.bst locally with a cp `kpsewhich agsm.bst` agsm-url.bst; 3. I patched the new agsm-url.bst file with the diff file mentioned before with patch agsm-url.bst < agsm-url.diff; 4. I copied the MWE and compiled it perfectly. – henrique Aug 23 '15 at 23:03
  • 1
    In case anybody has problems applying the patch, the patched file is at gist.github.com/moewew/6c65c256c9420d64f3b264c0a78774c0 – moewe Apr 17 '18 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.