I am writing a report in LaTeX for the Open University using Overleaf. The OU are insistent on a specific layout for online references as follows:
Surname, Initial. (Year) Title of web page. Available at: URL (Accessed: date).
with full block wrapping of the URL and no indent on the second and subsequent wrapped lines eg:
The best I have managed so far is
Surname, Initial. (Year) Title of web page. URL: URL (Accessed: date).
Where "URL:" is printed rather than "Available at:", the URL itself is in a monospaced font, 2nd & subsequent lines are indented. eg
Here is the compilable test document code which generates that output.
\documentclass{article}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, natbib]{biblatex} % 'backend=biber' is the default
\addbibresource{TestReferences.bib}
\usepackage{xurl}
\DefineBibliographyStrings{english}{urlseen = {Accessed:}}
\ExecuteBibliographyOptions{alldates=long}
\begin{document}
\subsection{Citation}
\citep{Hampton}
\printbibliography[heading=bibintoc,title={References}]
\end{document}
and here is the TestReferences.bib entry for the Hampton reference example above:
@Online{Hampton,
author = {{Hampton, D.L et al.}},
year = "2006",
title = {{‘An overview of the instrument suite for the deep impact mission'}},
url = {https://www.researchgate.net/publication/226736423_An_Overview_of_the_Instrument_Suite_for_the_Deep_Impact_Mission.},
urldate = {2024-04-23},
}
So my question is: how can I further configure the bibliography to remove the indents, get the "URL:" prompt changed to "Available at:", and get the font used to print the URL in the same font style as the rest of the reference as in the target example.
Please note: x-post tex.stackexchange.com/q/718641/36296
[Also posted on TeX SE as I'm not sure of the protocol for answering cross-posted questions.]
Note that you are almost certainly currently using US typesetting conventions, including US English hyphenation patterns. I doubt this is what the OU wants, so I've changed the code to use UK English. If, for some reason the OU wants US --- or if you are from the US and the OU allows US English --- change british
to american
(or back to english
).
Two of the three changes are straightforward. The third is not due to what appears to be a bug in Biblatex.
To remove the indentation, set the relevant length to 0pt
. This is a lot easier to figure out if you know which terms to search for in the documentation ;).
\setlength \bibhang {0pt}
The url
package is used to format URLs. This is loaded by xurl
. The font can be changed by redefining \UrlFont
, but we don't really want that. We want to not specify it at all, so define it to be empty.
\def\UrlFont{}
Note that the documentation suggests \def
rather than \renewcommand
, which is why I've used it here.
The less straightforward change is the label for the URL. In theory, Biblatex provides two strings for the label typeset prior to a URL: url
and urlfrom
.
\DefineBibliographyStrings{british}{urlseen = {Accessed:},urlfrom = {Available at}}
However, this has no effect. Neither does defining url
. Neither does changing the document language to Dutch in an attempt to get Biblatex to use the values from its own language definition file.
The documentation confirms the string should be localised as of a change more than a decade past. So this might be a regression or perhaps the change was never implemented correctly. In any case, I think you have to use brute force for this one and just override Biblatex here.
\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
Complete code:
\begin{filecontents*}[overwrite]{\jobname.bib}
@Online{Hampton,
author = {{Hampton, D.L et al.}},
year = "2006",
title = {{‘An overview of the instrument suite for the deep impact mission'}},
url = {https://www.researchgate.net/publication/226736423_An_Overview_of_the_Instrument_Suite_for_the_Deep_Impact_Mission.},
urldate = {2024-04-23},
}
\end{filecontents*}
\documentclass[british]{article}% seriously doubt the OU wants US hyphenation etc.
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear,natbib]{biblatex} % 'backend=biber' is the default
\addbibresource{\jobname.bib}
\usepackage{xurl}
\DefineBibliographyStrings{british}{urlseen = {Accessed:},urlfrom = {Available at}}
\ExecuteBibliographyOptions{alldates=long}
\setlength \bibhang {0pt}
\def\UrlFont{}
\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\begin{document}
\subsection{Citation}
\citep{Hampton}
\printbibliography[heading=bibintoc,title={References}]
\end{document}
Are you sure that the OU wants quotation marks as well as italics?