Hello.

I am trying to cite a webpage that uses the letter "ø", but my bibliography does not display the "ø" in the URL, making it look like it's not correct. I have searched for this problem for some ting, but I can only find solutions to either "Using æ/ø/å in bib(la)tex", or "Using æ/ø/å in hyperlinks".

I am using Overleaf and BibLatex.

The URL contains the letter ø, and ends up like this in my bibliography (The hyperlink works, but I would like it to display properly): https://www.matematikksenteret.no/eksamen-pr%C3%B8ver-og-kartlegging/alle-teller

It should be: https://www.matematikksenteret.no/eksamen-prøver-og-kartlegging/alle-teller

Disclaimer: I am not experienced in Latex at all, so there might be several other issues here as well. Please feel free to help me clean up other parts of my file too.

My biblatex entry looks like this:

@online{AlleTellerWeb,
author  = "NTNU",
title   = "Alle Teller",
url     = "https://www.matematikksenteret.no/eksamen-prøver-og-kartlegging/alle-teller",
year    = {2012},
urldate = {2018-09-16},
keywords = "NTNU, AlleTeller",
}

And here is a code-example:

\documentclass[a4paper,12pt]{article}
\usepackage[margin=24mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[colorlinks,urlcolor=blue,citecolor=blue,linkcolor=blue]{hyperref}
\usepackage{parskip}
\usepackage[norsk]{babel}
\usepackage{csquotes}
\usepackage[style=apa]{biblatex}
\DeclareLanguageMapping{norsk}{norsk-apa}
\addbibresource{Matematikk2.bib}

\begin{document}
\textit{Alle teller} er utviklet av professor Alistair McIntosh fra \textit{University of Tasmania} for å kartlegge barn sin talloppfatning og tallforståelse \parencite{AlleTellerWeb}.

\printbibliography

\end{document}
up vote 2 down vote accepted

Two issues play into this.

Firstly, Biber always encodes URLs into percent encoding. In particular non-ASCII characters like ø are converted into percent codes. In version 2.7 of Biber there used to be an option called --nouri-encode that would turn off this feature. It was replaced by a more sophisticated scheme with two fields (url contains the encoded string, urlraw contains the unprocessed string) in Biber 2.8 following https://github.com/plk/biber/issues/159. How to disable percent-encoding in URLs? and biblatex, using space in url doesnt work show how one would use urlraw and url to produce a link showing non-ASCII chars but linking to the percent-encoded URL

\DeclareFieldFormat{url}{%
  \mkbibacro{URL}\addcolon\space
  \ifhyperref
    {\href{#1}{\nolinkurl{\thefield{urlraw}}}}
    {\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter
     \nolinkurl
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter
     {\thefield{urlraw}}}}

As jfbu commented

\DeclareFieldFormat{url}{%
  \mkbibacro{URL}\addcolon\space
  \ifhyperref
    {\href{#1}{\nolinkurl{\thefield{urlraw}}}}
    {\expandafter\nolinkurl\expandafter{\romannumeral-`0\thefield{urlraw}}}}

does the same thing here and is easier on the eye.

Overleaf are running Biber 2.5 and so I'm afraid there is no way to make use of either the short-lived and now removed --nouri-encode or urlraw.

Then there is a second, more pressing issue. pdfLaTeX can't really deal with non-ASCII urls in \url or \nolinkurl. Have a look at the output of

\url{https://www.matematikksenteret.no/eksamen-prøver-og-kartlegging/alle-teller}

in your document. Ulrike also mentions and explains this in one of her answers. If you use XeLaTeX or LuaLaTeX the output is OK, but with pdfLaTeX you must build the URL yourself from low-level commands. The usual ad-hoc solution is very impractical for automatic tools such as biblatex and Biber, you could solve this by defining a new field urlmanual and using that instead of url.

Given all these difficulties I would just let it be and would accept the percent-encoded URLs if I were you.

  • I know nothing about this all, but I wonder if you need exactly 5 expansions and if \expandafter\nolinkurl\expandafter{\romannumeral-`0\thefield{urlraw}} could not be used instead ? I it could very well be though that this "full-first" expansion is not ok in this context. – jfbu Sep 17 at 7:13
  • @jfbu I know very little about TeX tricks like \romannumeral-`0, but in this case I'm quite sure five expansions steps are required to unpack \thefield{...} properly. \expandafter\nolinkurl\expandafter{\romannumeral-`0\thefield{urlraw}} seems to work as well, so I have added that as a shorter alternative. Thank you. – moewe Sep 17 at 9:46
  • The main limitation of the \romannumeral-`0 trick is that it will gobble a space token (and then stop) if it finds one upfront. The other danger is of course that it could expand too much which may not be the right thing to do. – jfbu Sep 17 at 11:03

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.