1

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:

enter image description here

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

enter image description here

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:", 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 stackoverflow.com/q/78520361/2777074

10
  • 1
    If you cross-post the same question on multiple sites, you should include links to all other versions of the question in every question. X-posting without explicit links has the risk of wasting both the time of users who might put time and effort into answering a post, which already has an answer elsewhere, as well as the time of users who might have the same problem but can't find the solutions you might have gotten on one of the other sites you x-posted your question Commented May 23 at 11:30
  • 2
    It might increase your chances to get an answer if you would provide a compilable test document. Commented May 23 at 11:31
  • 2
    Instead of author = {{Hampton, D.L et al.}}, it is usually better to give all names and not force the et al. manually. The example entry is actually a paper that was published in a journal, so @article would be more appropriate. Because there are so many names, the entry does not fit into the comments, but you can see what I would use at gist.github.com/moewew/97f90672187f2381cec33d0b90e52a15.
    – moewe
    Commented May 24 at 11:17
  • 2
    Note that if you absolutely do not want to give all author names in the .bib file and want to force "et al." manually (instead of having the style do that), you should use the and others keyword as in author = {D. L. Hampton and others},. (See e.g. tex.stackexchange.com/a/95956/35864.) But usually it's best to give all names and let the style do its thing.
    – moewe
    Commented May 24 at 11:18

1 Answer 1

3

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.

\urlstyle{same}% or \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}}

docs, brute force and ignorance -> 3 requested mods

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}
\urlstyle{same}%\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?

3
  • 1
    This is great many thanks. No, the OU would not want the quote marks as well - their inclusion is an error on my part. Thanks for noticing, they will be removed! Commented May 24 at 12:43
  • 2
    Instead of \def\UrlFont{} one could also use \urlstyle{same}, which has the exact same effect (it does \def\UrlFont{} under the hood), but feels higher level.
    – moewe
    Commented May 24 at 14:12
  • @moewe I didn't think that was the command I usually used but, when I looked in the manual, that's what I found. Clearly, I should have looked further. Thanks.
    – cfr
    Commented May 24 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .