[Tex/LaTex] Line breaks and the URL package

dvi-modeline-breakingurls

Long URLs need to be broken at the end of a line. Here's a topic about that. That topic suggests adding the hyphens option to the URL package, and also to define

\renewcommand{\UrlBreaks}{\do\/\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\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}

I've done both, but it still doesn't work. Below is a copy of an example. Any ideas?

\documentclass[10pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[swedish,english]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage[hyphens]{url}
\usepackage{hyperref}
\renewcommand{\UrlBreaks}{\do\/\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\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}

\usepackage{fixmath}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{color}
\usepackage[small,font=it]{caption}
\usepackage{amssymb}
\usepackage{icomma}
\usepackage{verbatim}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\setlength{\parindent}{0pt} 
\setlength{\parskip}{2ex}

\begin{document}

This is a test. Kurzweil says technology increases exponentially (\url{http://www.kurzweilai.net/the-law-of-accelerating-returns}).

\end{document}

EDIT: I am using latex and then dvipdf to compile.

Best Answer

I'm not sure what is causing the problem in the first place, but pdflatex gives the desired output without any fuss whatsoever. The issue seems to be reproducible only with a latex dvipdf or latex dvips ps2pdf build pattern. The DVI produced by latex exhibits this issue (viewed under xdvi), so it is no wonder that the trailing build processes fail.

A better solution must yet exist, but using pdflatex in the first place circumvents the issue for the most part. (The hyphenation patterns leave much to be desired.)

latex output: (DVI screenshot viewed under xvdi; the red line is the page edge) latex output

pdflatex output: pdflatex output

Related Question