6

I have code. In this code the url break in \printbibliography is not working. The url break in \url is working. Code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}

\begin{filecontents*}{references.bib}
    @misc
    {
        mybibkey,
        url = {http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}
    }
\end{filecontents*}
\addbibresource{references.bib}
\usepackage{hyperref}
\makeatletter
    \g@addto@macro\UrlBreaks
    {%
        \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
        \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
        \do\u\do\v\do\w\do\x\do\y\do\z\do\&\do\1\do\2\do\3%
        \do\4\do\5\do\6\do\7\do\8\do\9\do\0\do\/\do\.%
    }
    \g@addto@macro\UrlSpecials
    {%
        \do\/{\mbox{\UrlFont/}\hskip 0pt plus 2pt}%
    }
\makeatother
%\usepackage{breakurl}

\begin{document}

    See~\cite{mybibkey}.

    \printbibliography
    \noindent\url{http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}

\end{document}

Output: outputOfCode

I get a warning from writeLaTeX if I uncomment \usepackage{breakurl}:

/usr/share/texlive/texmf-dist/tex/latex/breakurl/breakurl.sty:
Package breakurl Warning: You are using breakurl while processing via pdflatex.

How to solve? There are many google entries and stack exchange entries about this issue but nothing is working.

  • 2
    biblatex has its own "url breaking" penalties. Use e.g. \setcounter{biburllcpenalty}{1} to allow breaks after lowercases. See the documentation for others. breakurl is sense- and useless with pdflatex. – Ulrike Fischer Oct 16 '14 at 7:45
7

Thanks to Ulrike Fischer I can post now the answer that I searched for. The three lines before \begin{document} are the key lines.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}

\begin{filecontents*}{references.bib}
    @misc
    {
        mybibkey,
        url = {http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}
    }
\end{filecontents*}
\addbibresource{references.bib}
\usepackage{hyperref}
\makeatletter
    \g@addto@macro\UrlBreaks
    {%
        \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
        \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
        \do\u\do\v\do\w\do\x\do\y\do\z\do\&\do\1\do\2\do\3%
        \do\4\do\5\do\6\do\7\do\8\do\9\do\0\do\/\do\.%
    }
    \g@addto@macro\UrlSpecials
    {%
        \do\/{\mbox{\UrlFont/}\hskip 0pt plus 10pt}%
    }
\makeatother
\setcounter{biburlucpenalty}{1}  %break URL after uppercase character
\setcounter{biburlnumpenalty}{1} %break URL after number
\setcounter{biburllcpenalty}{1}  %break URL after lowercase character

\begin{document}

    See~\cite{mybibkey}.

    \printbibliography
    \noindent\url{http://de.wikipedia.org/wiki/Elementarladungasdlfkjasalsdkfjhalskdjdfhjalksdjdfhjalksjdfhj}

\end{document}

Output:

outputOfCode

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.