35

I have a problem with the line break of an URL. The URL can´t break correct and extends into the border. I´ve tried some things. Amongst others I loaded the package breakurl, but without any success. When I set the bibliography left-aligned there isn´t a problem. But I need it justified. Here is an example:

\documentclass[
a4paper,                         
fontsize=11,                    
BCOR=10mm,
DIV=11
]{scrreprt}

\usepackage[ngerman]{babel}                    
\usepackage[latin1]{inputenc}                
\usepackage[T1]{fontenc}
\usepackage{lmodern}                        
\usepackage{microtype}    
\usepackage[
    style=numeric, 
    maxnames=1,
    bibencoding=latin1,
    backend=bibtex8,
    defernumbers=true,
    hyperref=true,
    alldates=long
]{biblatex}
\usepackage{hyperref}
\usepackage[hyphenbreaks]{breakurl}

\begin{filecontents}{bachelorarbeit_lit.bib}
@ONLINE{java96,
    author = {{Sun Microsystems}},
    title = {JavaSoft ships Java 1.0},
    year = {1996},
    month = {1},
    url = {http://findarticles.com/p/articles/mi_m0EIN/is_1996_Jan_23/ai_17853565/?tag=content;col1},
    urldate = {2011-03-02},
    sortname = {Sun},
    keywords = {www}
}

@ONLINE{java02,
    author = {{Computer Weekly}},
    title = {Write once, run anywhere?},
    year = {2002},
    month = {5},
    url = {http://www.computerweekly.com/Articles/2002/05/02/186793/Write-once-runanywhere1.htm},
    urldate = {2011-03-02},
    sortname = {Computer},
    keywords = {www}
}
\end{filecontents}

\bibliography{bachelorarbeit_lit}

\begin{document}
\chapter{Test}
Test \cite{java02}
Test \cite{java96}

%\raggedright
\printbibliography
\end{document}

Does anyone have an idea?

5
  • 1
    do not use package breakurl, when running pdflatex. hyperref does it anyway ...
    – user2478
    Apr 12, 2011 at 18:51
  • But without breakurl the problem is the same. Hyperref has an option breaklinks. But as far as i know this option doesn´t works. It will be set internally by the drivers.
    – MRae
    Apr 12, 2011 at 19:01
  • I removed the {biblatex} tag because the problem at hand may also arise with other bibliography packages.
    – lockstep
    Apr 12, 2011 at 19:43
  • 1
    A general hint that might be helpful whenever you're writing anything in English: For typing an apostrophe (as in can't), don't use the acute accent ´ (which is right of the sharp s ß, assuming you have a German keyboard), but instead the actual apostrophe ' by pressing shift + #. That'll give your LaTeX documents a way more professional look ;)
    – doncherry
    Apr 29, 2011 at 9:00
  • There will be a new solution for this problem in the near future (already tested and it will be uploaded to CTAN soon). Look at my question here: tex.stackexchange.com/a/108001/28200
    – MrD
    Apr 10, 2013 at 20:18

2 Answers 2

26

The first URL has a large unbreakable section (runanywhere1) which must either form the end of the second or the beginning of the third line (given the specific font size, margin etc. of the example) if one insists on justified text. An acceptable (?) solution may be obtained by adding e.g. \sloppy or \emergencystretch 1.5em before \printbibliography. enter image description here

1
  • Thanks for this answer. It is almost the same like the answer of Herbert and works too.
    – MRae
    Apr 12, 2011 at 19:24
37

try it this way: (without \usepackage[hyphenbreaks]{breakurl})

\begingroup
\raggedright
\sloppy
\printbibliography
\endgroup

Output, nicely spaced URLs with raggedright

or without \raggedright:

Output, nicely fittet URLs without raggedright

0

You must log in to answer this question.

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