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?

3

2 Answers 2

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}
1
  • 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
    Commented Apr 10, 2019 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)

1
  • 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 (tex.stackexchange.com/q/22854/35864).
    – moewe
    Commented Jan 23, 2023 at 5:57

You must log in to answer this question.

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