Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Did you try discretionary hyphens (\-)in the URL? Does \hyphenation remove the error? Maybe try out \hyp from the hyphenat package. (cf. Wikibooks article on Hyphenation) –  brian-ammon Jun 6 '12 at 9:32

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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