Is there a way of including a doi in agsm bibliography style? I know I can create my own file using latex makebst but I was hoping there was a way of altering the agsm.bst file to include doi in the references. Is there a way?
1 Answers
You could proceed as follows:
Find the file
agsm.bstin your TeX distribution. Make a copy of this file and call the copy, say,agsmdoi.bst. (Don't edit the fileagsm.bstdirectly.)Open the file
agsmdoi.bstin a text editor. The editor you use to edit your.texfiles will do fine.You first need to add a field type named
doi. To this effect, find theENTRYlist (it starts on ca. line 20 of the file). Find the lineschapter editionand insert the line
doibetween these two lines.
Find the function
write.url. (It'll should start around line 162.)After this function, insert the following code in the file to define a new function named
write.doi:FUNCTION {write.doi} { doi empty$ { "" } { new.block "doi: " doi * "" * } if$ }If you want to use a prefix other than
doi:, change the string to whatever suits your needs.Next, find the following group of four lines in each of about 14 functions -- starting with
FUNCTION {article}and ending withFUNCTION {unpublished}-- that serve to format and typeset the contents of these entry types:new.block note output fin.entry write.urlAssuming that you want the contents of the entry's
doifield to by typeset afternotebut beforeurl, you should insert the linewrite.doi outputbetween the lines that say
note outputandfin.entry; repeat up to 13 times. I suppose that if you know for sure that your bibliography will never contain entries of typemastersthesisorphdthesis, say, you can skip editing the corresponding functions. Likewise, if you know that certain entry types never have adoifield, you needn't edit the corresponding functions.Save the file
agsmdoi.bsteither in the same directory where your main tex file is stored or in a directory that's searched by BibTeX. If you choose the latter method, be sure to update the filename database of your TeX distribution.Use the modified bibliography style by issuing the command
\bibliographystyle{agsmdoi}. Run LaTeX, BibTeX, and LaTeX twice more to propagate all changes.
Here's a self-contained MWE (minimum working example) that uses the agsmdoi bibliography style. Note that I don't load the harvard package but, instead, both the natbib and har2nat packages; doing so provides full compatibility with the hyperref package (if that's needed). Note further the use of the \url{...} wrapper around the contents of the doi field. Providing this wrapper allows line breaks and provides a mechanism for making the doi string clickable if the hyperref package is loaded as well. Observe that this treatment is somewhat specific to working with the bibliography styles of the harvard package. If you used a style such as plainnat you should not provide an \url wrapper for doi fields.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{abcd:2013,
author = "Torben G. Andersen and Tim Bollerslev and Peter F. Christoffersen and Francis X. Diebold",
title = "Chapter 17 --- {Financial Risk Measurement for Financial Risk Management}",
editor = "George M. Constantinides and Milton Harris and Ren{\'e} M. Stulz",
publisher = "Elsevier",
year = "2013",
volume = "2, Part B",
pages = "1127-1220",
series = "Handbook of the Economics of Finance",
issn = "1574-0102",
doi = "\url{http://dx.doi.org/10.1016/B978-0-44-459406-8.00017-2}",
url = "http://www.sciencedirect.com/science/article/pii/B9780444594068000172",
}
\end{filecontents*}
\usepackage[margin=1.5in]{geometry}
\usepackage{natbib,har2nat,url}
\urlstyle{same}
\bibliographystyle{agsmdoi}
\begin{document}
\noindent
\citet{abcd:2013}
\bibliography{\jobname}
\end{document}
- 506,678