5

I've prepared my bibliography using biblatex, and my DOI addresses are not breaking their lines properly. I know that using pdflatex will solve this issue, I have to compile my document using latex -> dvips -> ps2pdf due to using pstricks.

Using the information from Biblatex: URL-breaking not working in DVI-mode, I tried using the breakurl package, and discovered that URLs line-break properly, but the DOIs still do not.

Any help would be appreciated. enter image description here

Here is a MWE

\documentclass{article}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\hypersetup{colorlinks,linkcolor=[RGB]{0,0,150}, citecolor=[RGB]{0,123,0},urlcolor=[RGB]{80,0,100}}
\usepackage[anythingbreaks]{breakurl}
\usepackage[citestyle=authoryear-comp,]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{liu2013condition,
title={Condition-based maintenance for continuously monitored degrading blah blah blah longer title},
author={Liu, Xiao and Li, Jingrui and Al-Khalifa, Khalifa N},
journal={IIE Transactions},
volume={45},
number={4},
pages={422--435},
year={2013},
publisher={Taylor and Francis},
doi = {10.1080/0740817X.2012.690930},
url={https://tex.stackexchange.com/questions/20768/how-to-allow-line-break-in-a-long-hyperlink-in-a-pdf-compiled-by-latex-dvips-ps2}
}
\end{filecontents}
\addbibresource{\jobname.bib} %Loads bibliography file
\usepackage[utf8]{inputenc}
\nocite{*}

\begin{document}

\printbibliography
\end{document}
jysung
  • 51
  • With your minimal example, i get a different output and the DOI looks ok. – Johannes_B Mar 25 '15 at 19:43
  • That may have been because I forgot to clean my aux files first. I tried it again, and updated the original question. Problem still persists, though. Is it possible that I'm using the wrong sequence of compilers? I am running biber each time too. – jysung Mar 25 '15 at 20:23
  • your example is faulty, there is a brace to much in the title. Beside this: DOI is set internally with \hrefand \nolinkurl and this doesn't work with breakurl. – Ulrike Fischer Mar 25 '15 at 22:18
  • Thank you, @ulrike-fischer. Does this mean that there is no solution to my problem? – jysung Mar 26 '15 at 02:37
  • Well enabling some break points should be easy, but you wouldn't get a sensible hyperlink then as the http://dx.doi.org/ would be missing. – Ulrike Fischer Mar 26 '15 at 08:21
  • Using http://shortdoi.org/ it is also possible to use DOI: \href{http://doi.org/992}{10/992}, or DOI: \href{http://dx.doi.org/10.1080/0740817X.2012.690930}{10/992} or DOI: \href{http://dx.doi.org/10/992}{10/992}. – Stephen Dec 22 '15 at 17:06

1 Answers1

4

DOI is set internally with \href and \nolinkurl and this doesn't work with breakurl. As far as I can see breakurl has no counterpoint to \nolinkurl, but this seems to work (and gives the correct link):

\documentclass{article}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\hypersetup{colorlinks,linkcolor=[RGB]{0,0,150}, citecolor=[RGB]{0,123,0},urlcolor=[RGB]{80,0,100}}
\usepackage[anythingbreaks]{breakurl}
\usepackage[citestyle=authoryear-comp,]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{liu2013condition,
title={Condition-based maintenance for continuously monitored degrading blah blah blah longer title},
author={Liu, Xiao and Li, Jingrui and Al-Khalifa, Khalifa N},
journal={IIE Transactions},
volume={45},
number={4},
pages={422--435},
year={2013},
publisher={Taylor and Francis},
doi = {10.1080/0740817X.2012.690930},
url={http://tex.stackexchange.com/questions/20768/how-to-allow-line-break-in-a-long-hyperlink-in-a-pdf-compiled-by-latex-dvips-ps2}
}
\end{filecontents}
\addbibresource{\jobname.bib} %Loads bibliography file
\usepackage[utf8]{inputenc}
\nocite{*}

\usepackage{expl3}
\ExplSyntaxOn
\newcommand \breakDOI[1]
 {
  \tl_map_inline:nn { #1 } { \href{http://dx.doi.org/#1}{##1} \penalty0 \scan_stop: }
 }
\ExplSyntaxOff

\DeclareFieldFormat{doi}{%
  \mkbibacro{DOI}\addcolon\space
  {\breakDOI{#1}}}


\begin{document}

\printbibliography
\end{document}

enter image description here

Ulrike Fischer
  • 327,261