# Not allowing hyphenation of urls in references

Is there a way to globally turn off hyphenation of links in bibliography? Current state doesn't please me:

Minmal working example:

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{url}
\usepackage{apacite}
\usepackage[T1]{fontenc}
\usepackage[osf]{libertine}
\begin{document}

\cite{mchinen}

\bibliographystyle{apacite}
\bibliography{general}
\end{document}


and here is the general.bib entry:

@url{mchinen,
Author = {Chinen, Michael},
Date-Modified = {2013-05-01 10:34:20 +0000},
Lastchecked = {March 23, 2013},
Title = {{M}ichael {C}hinen},
Url = {http://michaelchinen.com},
Urldate = {March 23, 2013},
Year = {2013},
Bdsk-Url-1 = {http://michaelchinen.com}}

• Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Qrrbrbirlbel May 14 '13 at 19:17
• @DownVoters: What’s the problem? – Qrrbrbirlbel May 14 '13 at 19:20
• It's a "balancing" problem: if you don't break the URL, the line will be way underfull. – egreg May 14 '13 at 20:19
• a way to avoid underfull/stretched lines in the bibliography (and thus avoid most breaks in urls) is to set it ragged right. but if a url is longer than the text width, you may have no alternative to breaking (not hyphenating) it to avoid it getting cut off as it runs off the edge of the paper. – barbara beeton May 14 '13 at 20:31
• Please do not use swearwords in your posts and images, even if they are meant as a joke. Please update your image accordantly. – Martin Scharrer May 16 '13 at 12:44

The break points set by package url can be configured by setting \UrlBreakPenalty and \UrlBigBreakPenalty. A value of 10000 prevents the hyphenation:

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{url}
\usepackage{apacite}
\usepackage[T1]{fontenc}
\usepackage[osf]{libertine}

\mathchardef\UrlBreakPenalty=10000
\mathchardef\UrlBigBreakPenalty=10000

\begin{document}

\cite{mchinen}

\begingroup
\raggedright
\bibliographystyle{apacite}
\bibliography{general}
\endgroup
\end{document}


Also the example uses \raggedright to avoid overstretched lines. You can also consider a slightly smaller value 9999 to make it possible to break URLs that do not fit in one line.