Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a slightly odd one. I've been trying to get \url{} blocks to wrap really long URLs, and the only thing that seemed to work was to renew the \UrlBreaks command to allow breaking on practically all characters.

However, whilst that prevents the long URL from overlapping the page margins, it seems to still push characters into the marginal notes spaces (defined by \marginparsep and \marginparwidth).

The following document shows the problem:

\RequirePackage[hyphens]{url}
\documentclass[12pt]{article}

\usepackage[hyphens]{url}
\PassOptionsToPackage{hyphens}{url}
\usepackage[colorlinks=true, urlcolor=blue]{hyperref}
\usepackage[margin=1cm, bottom=3.5cm, top=3.5cm, head=2cm]{geometry}
\usepackage{showframe}
\usepackage{blindtext}

\setlength\parindent{0pt}

\let\origUrlBreaks\UrlBreaks
\renewcommand*{\UrlBreaks}{\origUrlBreaks\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\do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\.\do\/\do\-\do\_\do\?\do\&\do\=}

\begin{document}

\blindtext

\url{http://really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-really-long-url.com}
\end{document}

When I compile it, half of the 'y' in really, and the entire '-' get pushed into the \marginparsep area. However, this does not seem to happen for blocks of regular text. See here:

enter image description here

Does anyone know why this happens, and what to do to fix it?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

There is no flexibility in your lines so TeX has nowhere to break.

Add

\Urlmuskip = 0mu plus 1mu

enter image description here

share|improve this answer
    
That was it. Cheers! –  Rsaesha Apr 10 '13 at 17:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.