[Tex/LaTex] Biblatex: bibliography force title to line break when needed

biblatexbibliographiespdfpdftex

Hey I recently discovered a problem in my bibliography and I somehow can't solve it. Its appearing when the titles are too long, but its working with urls normally as you see in the 2nd example as long the as the title is short enough.

It seems that symbols like "[]" beeing generated from something and the log is giving me 2x Overfull \hbox (X pt too wide) in paragraph. As soon as I remove the dots from the URL in the title it will break automatically like it should but it should actually see that the url is too big and break it automatically.

generated latex document

setup: document.tex and bib/literature.bib

settings: pdfLatex (using biber and texindy)

Minexample:

\documentclass[
    11pt,
    a4paper
]{scrreprt}

% add bibliography
\usepackage[style=alphabetic, sorting=anyt]{biblatex}
\addbibresource{bib/literature.bib}

\usepackage[colorlinks, urlcolor=blue]{hyperref}

\begin{document}
    \cite{Gaedke}
    \cite{IOT}

    \printbibliography
\end{document}

literature.bib

@online{Gaedke,
    author = {Gaedke, Martin and Heil, Andreas},
    title = {{GET /dgs HTTP/1.1 Host: www.WebComposition.net.}},
    url = {http://www.mendeley.com/research/dgs-http11-host-wwwwebcompositionnet/},
    urldate={2018-08-19}
}
@online{IOT,
    author = {Litzel, Nico },
    title = {Was ist das Internet of Things?},
    url = {https://www.bigdata-insider.de/was-ist-das-internet-of-things-a-590806/},
    urldate={2018-08-19}
}

Best Answer

Values for url are automatically wrapped, but in other contexts, you must mark them up appropriately. Moreover, the first entry should be @inproceedings and the second should have its date.

\begin{filecontents}{\jobname.bib}
@inproceedings{Gaedke,
    author = {Gaedke, Martin and Heil, Andreas},
    title = {{GET} {/dgs} {HTTP}/1.1 Host: \url{www.WebComposition.net}},
    url = {http://www.mendeley.com/research/dgs-http11-host-wwwwebcompositionnet/},
    urldate={2018-08-19},
    booktitle = {Proceedings of the 42nd Annual Hawaii International Conference on System Sciences},
    date = 2009,
    organization = {HICSS},
}
@online{IOT,
    author = {Litzel, Nico},
    title = {Was ist das Internet of Things?},
    url = {https://www.bigdata-insider.de/was-ist-das-internet-of-things-a-590806/},
    urldate={2018-08-19},
    date = {2016-01-09},
}
\end{filecontents}

\documentclass[11pt, a4paper]{scrreprt}
\usepackage[style=alphabetic, sorting=anyt]{biblatex}
\addbibresource{\jobname.bib}
\usepackage[colorlinks, urlcolor=blue]{hyperref}

\begin{document}
\cite{Gaedke}
\cite{IOT}

\printbibliography
\end{document}

output

This does break the URL in the title, though we still get a bad box because TeX can't figure out a good way to break up the URL further. Or, more likely the url package or hyperref's version cannot.

If you want the URLs to be broken regardless, you can set the penalties accordingly. For example, adding

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

produces

alternative output

instead.

\documentclass[11pt, a4paper]{scrreprt}
\usepackage[style=alphabetic, sorting=anyt]{biblatex}
\addbibresource{\jobname.bib}
\usepackage[colorlinks, urlcolor=blue]{hyperref}
\setcounter{biburlnumpenalty}{9000}
\setcounter{biburlucpenalty}{9000}
\setcounter{biburllcpenalty}{9000}
\begin{document}
\cite{Gaedke}
\cite{IOT}

\printbibliography
\end{document}
Related Question