3

When using biblatex with a long URL without many forward slashes the URL overflows outside of the margins of the page.

For example:

references.bib

@online{ons,
    author = "Office for National Statistics",
    title = "Overview of the UK population: July 2017",
    url = {https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/articles/overviewoftheukpopulation/july2017},
    year = "2017"
}

main.tex

\documentclass[12pt,a4paper]{article}

\usepackage[style=ieee,citestyle=ieee,dashed=false]{biblatex}
\addbibresource{references.bib}

\begin{document}
    Lots of text
    ...
    \cite{ons}
    \newpage
    \printbibliography
\end{document}

Produces the following result: enter image description here

How can this be fixed?

Mico
  • 506,678
  • 3
    Welcome to tex.sx. There are lots of other questions about this problem. This one may contain some useful information. – barbara beeton Apr 10 '19 at 17:49
  • 3
    Note that you should be wrapping so-called corporate authors like Office for National Statistics in an additional pair of braces (https://tex.stackexchange.com/q/10808/35864): author = {{Office for National Statistics}},. You should also protect UK and July in the title from unwanted case change: title = {Overview of the {UK} population: {July} 2017}, (https://tex.stackexchange.com/q/10772/35864). – moewe Apr 10 '19 at 17:52
  • 1
    There are also https://tex.stackexchange.com/q/22854/35864, https://tex.stackexchange.com/q/30857/35864 – moewe Apr 10 '19 at 17:54

2 Answers2

3

Three suggestions:

  • Load the xurl package. It allows line breaks in URL strings at arbitrary positions.

  • Encase the author field in an extra pair of curly braces, so that biber/bibtex doesn't misinterpret the name as consisting of first name component "Office", von component "for", and surname component "National Statistics". Observe that in the screenshot you posted, the "first name component" got truncated to its initial, "O.". Not good!

  • Encase the word UK in a pair of curly braces, to keep it from getting lowercased. Again, look at the screenshot you posted: The word "UK" got rendered as "uk". Not good!

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{references.bib}
@online{ons,
    author = "{Office for National Statistics}",
    title = "Overview of the {UK} population: July 2017",
    url = {https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/articles/overviewoftheukpopulation/july2017},
    year = "2017"
}
\end{filecontents}

\documentclass[12pt,a4paper]{article}
\usepackage[style=ieee,citestyle=ieee,dashed=false]{biblatex}
\addbibresource{references.bib}
\usepackage{xurl}
\begin{document}
    \cite{ons}
    \newpage
    \printbibliography
\end{document}
Mico
  • 506,678
  • 1
    An additional comment: I believe that the BibTeX style file IEEEtran.bst typesets URL strings using the basic ("roman") text font, not in a monospaced font as is shown in the screenshot above. If you need to copy the IEEEtran settings, simply add the instruction \urlstyle{same} after loading the xurl package. – Mico Apr 10 '19 at 18:06
0

You can also use the package url package.

See this answer

The difference between xurl and url you can find in this answer

(short: the package xurl loads the package url and adds some capabilities)

DEner
  • 3
  • 1
    biblatex already loads the url package, so you don't need to load it explicitly unless you need to pass options to it. biblatex already extends url's capabilities a bit to allow finer control over breaks (https://tex.stackexchange.com/q/22854/35864). – moewe Jan 23 '23 at 05:57