On 06/03/2012 05:38 AM, Charlie wrote:

I'm certain it's been discussed here before, but I can't find a
reference to it.

The way to stop a URL as an "insert URL" from running out over the
margins into infinity. This happens in various document classes.

The first line of the Insert URL has the right idea, but the second one
doesn't stop at any margin.

I know it can be done easily without using the insert URL application,
but then the URL can't just be clicked on in the .pdf version to take
the reader to the location. Instead it needs to be copied and pasted
into a browser address bar.

I think it should be possible to show the URL in a different way, even
if it's just a link to the correct page.

Just thought I would ask if someone can point me to the location of the
discussion.

There's a good discussion on the page
http://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url

The solution to just add

\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\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\?}

to the preamble seems to work for me with pdfLatex, but not with
Postscript.  It lets Latex do a line break after a forward slash or
any alphabetic character.  I also added numbers and some punctuation
symbols, though a few are probably superfluous.  (Any character which
is not on the list but is in the URL seems to make the line breaks
overhang just slightly, by a character.)  The only downside seems to
be that the breaks are placed arbitrarily in the URL.

A different option would be to use \href directly in an ERT:

\def\ab{\allowbreak}
\href{http://longURL.com/thisIsALongStringWhichCanBreakBetweenWords}
{\texttt{http://longURL.com/this\ab Is\ab A\ab Long\ab String\ab
Which\ab Can\ab Break\ab Between\ab Words}}

Note that this allows breaks wherever the \ab is.  It also allows
for the text of the link to be different from the URL itself, so
you could just substitute some descriptive phrase in place of the
full URL in the second argument.  (Without \texttt it will be in
the same font as the surrounding text, just like a hyperlink.)
In pdfLatex the links are clickable, but even in Postscript they
seem to print and line-break OK.  Unfortunately, the Latex
\allowbreak command cannot be entered from the Insert > Hyperlink
dialog.





Reply via email to