To get the desired output, you need to change the \URLprefix
macro (to change the prefix before the URL string), the print.url
function (to suppress printing if a non-empty doi
string is present), and the fin.entry
function (to suppress the .
at end of the formatted entry.
Change the instruction (ca. line 1686)
"\providecommand{\URLprefix}{URL: }"
to
"\providecommand{\URLprefix}{Retrieved from }"
Change the print.url
function (starts ca. line 995) from
FUNCTION {print.url}
{url duplicate$ empty$
{ pop$ "" }
{ new.sentence
urlprefix "\url{" * swap$ * "}" *
}
if$
}
to
FUNCTION {print.url}
{url duplicate$ empty$
{ pop$ "" }
{ doi empty$
{ new.sentence
urlprefix "\url{" * swap$ * "}" * }
{ pop$ "" }
if$
}
if$
}
The new code chunk checks if the doi
field is empty; only if that's the case, the formatted contents of the url
field are printed.
Change the fin.entry
function so that it looks like this (this will suppress printing a .
if either a doi
or a url
field is non-empty, incorporating your earlier query):
FUNCTION {fin.entry}
{ doi empty$
{ url empty$
{ add.period$ }
{ }
if$
}
{ }
if$
write$
newline$
}
Addendum: Here's an MWE (minimum working example) that has two bib entries: one with both url
and doi
fields, and one with only a url
field. If both fields are present, only the doi
is printed; if only a url
field is present, it's printed out, prefixed by "Retrieved from URL address ". (A separate comment: the modified bst file incorporates your earlier two requests as well: (i) showing the number
field, in parentheses, and (ii) no period at end of entry if doi
field is printed.)

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{abc,
author = "Anne Author",
title = "An entry with both doi and url fields",
journal = "Thoughts",
year = 3001,
volume = 1,
number = 2,
pages = "3-4",
url = "http://xyz.com",
doi = 12345678,
}
@article{def,
author = "Annie Author",
title = "An entry with only a url field",
journal = "Thoughts",
year = 3002,
volume = 5,
number = 6,
pages = "7-8",
url = "http://xyz.com",
}
\end{filecontents}
\documentclass{article}
\bibliographystyle{mymodel5}
\usepackage{url,natbib}
\begin{document}
\nocite{*}
\bibliography{mybib}
\end{document}
doi
field is printed (in case it's non-empty, of course)?\newcommand{\DOIprefix}{http://dx.doi.org/} % Text before DOI number.
\newcommand{\doi}[1]{\textrm{#1}} % Changes the font of DOIs.
It think will do if it is left as it is in the bst file... But if you know a better way to do this, let me know!