Discussion:
problem with URL not breaking properly
(too old to reply)
Phillip Helbig (undress to reply)
2020-04-16 10:48:16 UTC
Permalink
On an old LaTeX installation, things work fine, with one bug I can
correct: the URL gets broken by a % (i.e. to make LaTeX ignore the line
break) if it is a bit long, which I have to remove as it shows up in the
URL itself.

However, on a newer installation, the problem above doesn't occur, but
some (but not all---maybe http but not https) URLs get doubled up:
\url{\url{textofurl}}. Annoying, but can also be corrected by hand in
the .bbl.

However, on the newer installation, the URLs are not broken.

I tried using just hyperref. A suggestion to load url with the hyphens
options before hyperref leads to an options-clash error. So now I have

%\usepackage[hyphens]{url}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}

But the behavious is still the same, on both the old and new systems.

The package is mnras.cls.

My guess is that I am not the first to have this problem. If there are
no quick answers, I'll try to come up with a MWE.
Peter Flynn
2020-04-16 13:21:20 UTC
Permalink
Post by Phillip Helbig (undress to reply)
On an old LaTeX installation, things work fine, with one bug I can
correct: the URL gets broken by a % (i.e. to make LaTeX ignore the line
break) if it is a bit long, which I have to remove as it shows up in the
URL itself.
However, on a newer installation, the problem above doesn't occur, but
\url{\url{textofurl}}. Annoying, but can also be corrected by hand in
the .bbl.
However, on the newer installation, the URLs are not broken.
I tried using just hyperref. A suggestion to load url with the hyphens
options before hyperref leads to an options-clash error. So now I have
%\usepackage[hyphens]{url}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
AFAIK the \PassOptionsToPackage command must be the first line in your
document, BEFORE \documentclass. You then just say (lower down)
\usepackage{url}

Peter
Ulrike Fischer
2020-04-16 13:39:32 UTC
Permalink
Post by Peter Flynn
AFAIK the \PassOptionsToPackage command must be the first line in your
document, BEFORE \documentclass.
No. It should be only before the package to which you want to pass
the option is loaded (which could mean before the class, in case the
class is loading the package).
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
Phillip Helbig (undress to reply)
2020-04-16 17:19:05 UTC
Permalink
Post by Ulrike Fischer
Post by Peter Flynn
AFAIK the \PassOptionsToPackage command must be the first line in your
document, BEFORE \documentclass.
No. It should be only before the package to which you want to pass
the option is loaded (which could mean before the class, in case the
class is loading the package).
OK. In my case, the class was loading the package.
Peter Flynn
2020-04-16 20:34:19 UTC
Permalink
Post by Ulrike Fischer
Post by Peter Flynn
AFAIK the \PassOptionsToPackage command must be the first line in your
document, BEFORE \documentclass.
No. It should be only before the package to which you want to pass
the option is loaded (which could mean before the class, in case the
class is loading the package).
Oh right. Thank you.

So if you are using hyperref, you would say

\PassOptionsToPackage{hyphen}{url}
\usepackage{hyperref}

because hyperref loads url?

Peter
Phillip Helbig (undress to reply)
2020-04-16 20:48:42 UTC
Permalink
Post by Peter Flynn
Post by Ulrike Fischer
Post by Peter Flynn
AFAIK the \PassOptionsToPackage command must be the first line in your
document, BEFORE \documentclass.
No. It should be only before the package to which you want to pass
the option is loaded (which could mean before the class, in case the
class is loading the package).
Oh right. Thank you.
So if you are using hyperref, you would say
\PassOptionsToPackage{hyphen}{url}
\usepackage{hyperref}
because hyperref loads url?
I think so. But does hyperref (still) actually load url?

In any case, my original problem doesn't occur with pdflatex, but does
occur with latex. So perhaps it is a bug in dvips.
Ulrike Fischer
2020-04-16 21:44:10 UTC
Permalink
Am Thu, 16 Apr 2020 20:48:42 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Post by Peter Flynn
because hyperref loads url?
I think so. But does hyperref (still) actually load url?
Yes.
Post by Phillip Helbig (undress to reply)
In any case, my original problem doesn't occur with pdflatex, but does
occur with latex. So perhaps it is a bug in dvips.
No.
--
Ulrike Fischer
https://www.troubleshooting-tex.de/
Phillip Helbig (undress to reply)
2020-04-17 05:25:47 UTC
Permalink
Post by Ulrike Fischer
Am Thu, 16 Apr 2020 20:48:42 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Post by Peter Flynn
because hyperref loads url?
I think so. But does hyperref (still) actually load url?
Yes.
I didn't see it mentioned explicitly in the log file, but do with other
packages which load still other packages.
Post by Ulrike Fischer
Post by Phillip Helbig (undress to reply)
In any case, my original problem doesn't occur with pdflatex, but does
occur with latex. So perhaps it is a bug in dvips.
No.
Any idea what the problem is?

http://www.astro.multivax.de:8000/mwe/

Perhaps not completely minimal, but illustrates the problem.
Ulrike Fischer
2020-04-17 06:55:05 UTC
Permalink
Am Fri, 17 Apr 2020 05:25:47 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Any idea what the problem is?
http://www.astro.multivax.de:8000/mwe/
Perhaps not completely minimal, but illustrates the problem.
I will not follow such a link and debug some non-minimal code.
Provide a **minimal** example here if you want my help.
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
Phillip Helbig (undress to reply)
2020-04-17 09:17:17 UTC
Permalink
Post by Ulrike Fischer
Am Fri, 17 Apr 2020 05:25:47 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Any idea what the problem is?
http://www.astro.multivax.de:8000/mwe/
Perhaps not completely minimal, but illustrates the problem.
I will not follow such a link and debug some non-minimal code.
Provide a **minimal** example here if you want my help.
See below (after "=============").

At http://www.astro.multivax.de:8000/mwe/ are test.tex (included below),
the files produced by running an old version of LaTeX, and, for
comparison, the pdf file generated from that (test_oldlatex.pdf:
correctly broken URLs, but they aren't active links (not sure why, not
worth worrying about, but demonstrates that the line-break problem
doesn't occur with an old version of LaTeX)), a pdf file generated from
a reasonably new installation (test_latex.pdf: URLs are working links
but do not have line-breaks), and a pdf file generated from a reasonably
new installation of pdflatex on the same machine (test_pdflatex.pdf:
URLs are active links and are correctly broken at the end of the lines).

=============

\documentclass[a4paper,twocolumn]{article}
\usepackage{hyperref}

\title{Test}
\author{Phillip Helbig}

\setlength{\columnwidth}{5cm}

\begin{document}

\maketitle

\bibliographystyle{plain}
\begin{thebibliography}{43}
%\expandafter\ifx\csname natexlab\endcsname\relax\def\natexlab#1{#1}\fi
\bibitem[{Coles(2009)}]{PColes09a}
Coles P., 2009, The cosmic tightrope.
\url{https://telescoper.wordpress.com/2009/05/03/the-cosmic-tightrope/}
\bibitem[{Schmidt(1989)}]{MSchmidt89a}
Schmidt M., 1989, Interview of {M}aarten {S}chmidt by {A}lan {L}ightman on 1989
{M}arch 28, {N}iels {B}ohr {L}ibrary \& {A}rchives, {A}merican {I}nstitute of
{P}hysics, {C}ollege {P}ark, {MD} {USA}. online,
\url{https://www.aip.org/history-programs/niels-bohr-library/oral-histories/33967}
\end{thebibliography}


\end{document}
Ulrike Fischer
2020-04-17 10:01:39 UTC
Permalink
Am Fri, 17 Apr 2020 09:17:17 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Post by Ulrike Fischer
I will not follow such a link and debug some non-minimal code.
Provide a **minimal** example here if you want my help.
See below (after "=============").
Geht doch.
Post by Phillip Helbig (undress to reply)
correctly broken URLs, but they aren't active links (not sure why, not
worth worrying about, but demonstrates that the line-break problem
doesn't occur with an old version of LaTeX))
No it demonstrates that the problem is related to links. hyperref
actively disables link breaking on the dvips route as the driver
doesn't support this, and even if you try to force it with
breaklinks=true it won't work with url as the penalties are lost
after the box/unboxing of hyperref.

Use the already suggested package breakurl.
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
Phillip Helbig (undress to reply)
2020-04-17 12:44:53 UTC
Permalink
Post by Ulrike Fischer
Post by Phillip Helbig (undress to reply)
correctly broken URLs, but they aren't active links (not sure why, not
worth worrying about, but demonstrates that the line-break problem
doesn't occur with an old version of LaTeX))
No it demonstrates that the problem is related to links.
The file with proper line breaks but no active links was generated on a
really old installation, but with the same packages (not necessarily the
same versions). But it is not worth worrying about problems in an old
installation. I do want things to work with a modern installation,
though.
Post by Ulrike Fischer
hyperref
actively disables link breaking on the dvips route as the driver
doesn't support this, and even if you try to force it with
breaklinks=true it won't work with url as the penalties are lost
after the box/unboxing of hyperref.
OK, makes sense. So it's not a bug in dvips per se, but rather lack of
functionality. :-) That also explains why there is no such problem
with pdflatex.
Post by Ulrike Fischer
Use the already suggested package breakurl.
I'll give it a try. But will that result in a) working links b) which
are correctly broken across lines if they are too long? If not, then it
doesn't really solve my problem. If so, then shouldn't hyperref load
breakurl?
Kevin Ryde
2020-04-19 01:24:11 UTC
Permalink
Post by Phillip Helbig (undress to reply)
But will that result in a) working links
Believe so, but I've only gone to dvi or postscript and don't think say
ghostscript gv has a notion of links.
Post by Phillip Helbig (undress to reply)
b) which are correctly broken across lines if they are too long?
Yes. There's an option to break at hyphens like in your example too,
with the caveat in its docs about possible ambiguity for the human reader.
Phillip Helbig (undress to reply)
2020-04-19 07:29:02 UTC
Permalink
This post might be inappropriate. Click to display it.
Ulrike Fischer
2020-04-19 13:07:16 UTC
Permalink
Am Sun, 19 Apr 2020 07:29:02 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Normally, the URL package will break correctly, so it seems strange to
need to add breakurl because of hyperref.
active links in a pdf are basically rectangles (or a number of
rectangles if links are broken over lines). To create the rectangles
one has to calculate the coordinates. pdftex with pdf output has
in-built commands for this. But on the latex->dvips->pdf route one
has to measure the url on the latex side to get the coordinates and
write them in the postscript. Measuring means boxing and boxing
prevents line breaks, and even if one unbox it can affect penalties
and so line breaking again.

The hypdvips package contains code to enable link breaking, but it
works only for normal text, not with urls as the penalties are still
lost. Also as ghostscript decided to change the way link borders are
calculated the one produced by hypdvips are currently wrong in
texlive 2020.

So breakurl is currently the only really working option for url on
the dvips route.
--
Ulrike Fischer
https://www.troubleshooting-tex.de/
Axel Berger
2020-04-19 16:40:02 UTC
Permalink
Measuring means boxing and boxing prevents line breaks,
Thank you. I already knew about the problem but now I understand it.

Danke
Axel
--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --
Dr Eberhard Lisse
2020-04-20 11:00:33 UTC
Permalink
Thank you,

or as they say, me three :-)-O

el
Post by Axel Berger
Measuring means boxing and boxing prevents line breaks,
Thank you. I already knew about the problem but now I understand it.
Danke
Axel
--
If you want to email me, replace nospam with el
Phillip Helbig (undress to reply)
2020-04-19 15:04:55 UTC
Permalink
Post by Ulrike Fischer
So breakurl is currently the only really working option for url on
the dvips route.
I had never used pdflatex before, but have used it now to get around
this problem. But I'll probably load breakurl and go back to
dvips/ps2pdf because I like the intermediate dvi.

Is there any reason to prefer pdflatex to latex?

Is it still true that pdflatex can include pdf files but not PostScript
files? (Yes, it is easy to convert PostScript to PDF, but this seems a
strange limitation, or is the idea to prevent people from distributing
(potentially large, since uncompressed) PostScript files?
Pieter van Oostrum
2020-04-19 19:20:13 UTC
Permalink
Post by Phillip Helbig (undress to reply)
Is there any reason to prefer pdflatex to latex?
It is the best way to produce PDF, which is preferred over PS as a standard in these days. And, as you have seen, some things work better with pdflatex.
Post by Phillip Helbig (undress to reply)
Is it still true that pdflatex can include pdf files but not PostScript
files? (Yes, it is easy to convert PostScript to PDF, but this seems a
strange limitation, or is the idea to prevent people from distributing
(potentially large, since uncompressed) PostScript files?
PDF readers/viewers cannot interpret PS, as this is quite different from PDF (although there are superficial resemblances). So the PDF must be converted before it is included in a PDF file, for example to PDF or PNG.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
Ulrike Fischer
2020-04-19 19:58:57 UTC
Permalink
Am Sun, 19 Apr 2020 15:04:55 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Is there any reason to prefer pdflatex to latex?
it is faster. And from the coding point much easier. You don't have
to understand postscript and how ghostscript or the distiller
handles it to get something in the pdf.
Post by Phillip Helbig (undress to reply)
Is it still true that pdflatex can include pdf files but not PostScript
files?
pdf can not contain eps directly. You always have to convert it to
pdf first, also with dvips - there it is done by ghostscript.

With pdflatex it is now done on-the-fly in the background by calling
epstopdf.
--
Ulrike Fischer
https://www.troubleshooting-tex.de/
Phillip Helbig (undress to reply)
2020-04-19 20:48:20 UTC
Permalink
Post by Ulrike Fischer
Post by Phillip Helbig (undress to reply)
Is there any reason to prefer pdflatex to latex?
it is faster. And from the coding point much easier. You don't have
to understand postscript and how ghostscript or the distiller
handles it to get something in the pdf.
So, for a user with a reasonably fast machine, not a noticeable
difference, but easier for those developing (pdf)latex?
Post by Ulrike Fischer
Post by Phillip Helbig (undress to reply)
Is it still true that pdflatex can include pdf files but not PostScript
files?
pdf can not contain eps directly. You always have to convert it to
pdf first, also with dvips - there it is done by ghostscript.
With pdflatex it is now done on-the-fly in the background by calling
epstopdf.
What I meant is using includegraphics or whatever to point to a
PostScript file in the .tex file. Is that possible, or do I have to
convert it to PDF first?
Ulrike Fischer
2020-04-20 08:56:59 UTC
Permalink
Am Sun, 19 Apr 2020 20:48:20 +0000 (UTC) schrieb
Post by Phillip Helbig (undress to reply)
Post by Ulrike Fischer
With pdflatex it is now done on-the-fly in the background by calling
epstopdf.
What I meant is using includegraphics or whatever to point to a
PostScript file in the .tex file. Is that possible, or do I have to
convert it to PDF first?
Why don't you try?
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
Phillip Helbig (undress to reply)
2020-04-20 10:20:16 UTC
Permalink
Post by Ulrike Fischer
Post by Phillip Helbig (undress to reply)
Post by Ulrike Fischer
With pdflatex it is now done on-the-fly in the background by calling
epstopdf.
What I meant is using includegraphics or whatever to point to a
PostScript file in the .tex file. Is that possible, or do I have to
convert it to PDF first?
Why don't you try?
Because I'm too busy. :-)

Also, I suppose it is possible that it might sometimes work but not
always and/or only with certain versions or whatever.
Dr Eberhard Lisse
2020-04-20 11:15:52 UTC
Permalink
Well,

as the name says, pdflatex produces pdf. And it avoids a lot of these
dvips/ps2pdf problems.

I would be interested whether lualaTeX which has much more
possibilities, runs on these ancient toys you seem to like playing with.

I like to run

https://www.complang.tuwien.ac.at/anton/latex-bench/

and if I can with

https://github.com/Gabriel439/bench

would love to see the results for pdflatex and lualatex on your DEC

VMS is/was cool, started on it myself, but MacTeX is darn good.

el
Post by Phillip Helbig (undress to reply)
Post by Ulrike Fischer
So breakurl is currently the only really working option for url on
the dvips route.
I had never used pdflatex before, but have used it now to get around
this problem. But I'll probably load breakurl and go back to
dvips/ps2pdf because I like the intermediate dvi.
Is there any reason to prefer pdflatex to latex?
Is it still true that pdflatex can include pdf files but not PostScript
files? (Yes, it is easy to convert PostScript to PDF, but this seems a
strange limitation, or is the idea to prevent people from distributing
(potentially large, since uncompressed) PostScript files?
--
If you want to email me, replace nospam with el
Phillip Helbig (undress to reply)
2020-04-16 17:18:28 UTC
Permalink
Post by Peter Flynn
Post by Phillip Helbig (undress to reply)
On an old LaTeX installation, things work fine, with one bug I can
correct: the URL gets broken by a % (i.e. to make LaTeX ignore the line
break) if it is a bit long, which I have to remove as it shows up in the
URL itself.
However, on a newer installation, the problem above doesn't occur, but
\url{\url{textofurl}}. Annoying, but can also be corrected by hand in
the .bbl.
However, on the newer installation, the URLs are not broken.
I tried using just hyperref. A suggestion to load url with the hyphens
options before hyperref leads to an options-clash error. So now I have
%\usepackage[hyphens]{url}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
AFAIK the \PassOptionsToPackage command must be the first line in your
document, BEFORE \documentclass. You then just say (lower down)
\usepackage{url}
Good to know, but probably irrelevant here. (Some examples I found
didn't have it at the very top.)
David Underwood
2020-04-16 15:56:13 UTC
Permalink
Post by Phillip Helbig (undress to reply)
On an old LaTeX installation, things work fine, with one bug I can
correct: the URL gets broken by a % (i.e. to make LaTeX ignore the line
break) if it is a bit long, which I have to remove as it shows up in the
URL itself.
However, on a newer installation, the problem above doesn't occur, but
\url{\url{textofurl}}. Annoying, but can also be corrected by hand in
the .bbl.
However, on the newer installation, the URLs are not broken.
I tried using just hyperref. A suggestion to load url with the hyphens
options before hyperref leads to an options-clash error. So now I have
%\usepackage[hyphens]{url}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
But the behavious is still the same, on both the old and new systems.
The package is mnras.cls.
My guess is that I am not the first to have this problem. If there are
no quick answers, I'll try to come up with a MWE.
I use package xurl, to direct package url to break URLs.

Dave Underwood
Phillip Helbig (undress to reply)
2020-04-16 17:20:36 UTC
Permalink
Post by David Underwood
Post by Phillip Helbig (undress to reply)
My guess is that I am not the first to have this problem. If there are
no quick answers, I'll try to come up with a MWE.
I use package xurl, to direct package url to break URLs.
For me, they break fine with just the url package. The problem is
hypertex.

I've since learned that this problem does not exist in pdflatex.

It would still be nice to know if it is a bug in LaTeX. While there
might be reasons to use pdflatex instead of latex, I don't think that a
relatively minor bug in latex should be one of them.
Kevin Ryde
2020-04-16 23:16:48 UTC
Permalink
Post by Phillip Helbig (undress to reply)
I've since learned that this problem does not exist in pdflatex.
breakurl package does some stuff helping plain latex making dvi output.
I don't actually know how much hyperref or url do themselves these days,
but I had a long url not breaking and put breakurl and then it did break
so that's good :).

I believe breakurl must be after hyperref. (And if you use whizzytex
then it upsets breakurl, so either omit breakurl while previewing, or
conditionalize.)
Dr Eberhard Lisse
2020-04-20 11:06:03 UTC
Permalink
Thank you,

you just made my week.

Xurl dramatically improves the looks of the (BibTeX) bibliography on a
little project of mine nearing completion.

el


On 16/04/2020 17:56, David Underwood wrote:
[...]
Post by David Underwood
I use package xurl, to direct package url to break URLs.
Dave Underwood
--
If you want to email me, replace nospam with el
Loading...