7

I'm using biblatex and I'm quoting a commit on github that looks like this:

http://github.com/torvalds/linux/commit/693d92a1bbc9e42681c42ed190bd42b636ca876f

The biblatex-entry looks like this,

@online{Torvalds11,
  author = {Linus Torvalds},
  title = {Linux Makefile: Commit 693d92a},
  url = {http://github.com/torvalds/linux/commit/693d92a1bbc9e42681c42ed190bd42b636ca876f}
}

The result looks like this.

Screenshot of bib entry

UI tried to insert a space character but that didn't work. How to force latex to break that url at the end of the line?

MWE:

\documentclass{report}
 \usepackage[english]{babel}
 \usepackage{lipsum}
 \usepackage{biblatex}
  \bibliography{mwe}
 \usepackage[babel]{csquotes}
 \usepackage{hyperref}

 \begin{document}
  \lipsum[100]\cite{Torvalds11}
  \printbibliography
 \end{document}

I found this: How to deal with bibliography items containing long URLs? But the suggested answers are not compatible with my document as I'm using hyperref package already and it should automatically break urls at the end of the lines. I guess this url is a special problem.

2

I'd resort to a work-around and use a URL shortener for this URL [1], since noone is going to type in this URL anyways...

[1] maybe even github's own: https://github.com/blog/985-git-io-github-url-shortener

7

The biblatex package has a facility for this:

\begin{filecontents*}{\jobname.bib}
@online{Torvalds11,
  author = {Linus Torvalds},
  title = {Linux Makefile: Commit 693d92a},
  url = {http://github.com/torvalds/linux/commit/693d92a1bbc9e42681c42ed190bd42b636ca876f}
}
\end{filecontents*}
\documentclass{report}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{biblatex}

\setcounter{biburlnumpenalty}{9000}
\setcounter{biburlucpenalty}{9000}
\setcounter{biburllcpenalty}{9000}

\bibliography{\jobname}

\usepackage[babel]{csquotes}
\usepackage{hyperref}

\begin{document}
\lipsum[100]\cite{Torvalds11}
\printbibliography
\end{document}

However, this affects all URLs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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