Breakurl does not work with htmladdnormallink
Thomas Schneider
schneidt at mail.nih.gov
Sun Aug 29 08:57:14 CEST 2021
Dear TeXers and Vilar Camara Neto:
I am using:
% latex --version
pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2021)
which has:
breakurl version 1.40 (2013/04/10)
My URLs break with \url but not with \htmladdnormallink. I looked
into the source code for breakurl
https://ctan.org/pkg/breakurl?lang=en
and found that the file breakurl.dtx is the actual source code. It
has this line:
\DeclareRobustCommand{\burl}{\url}
and later
% Now the synonyms |\url| and |\urlalt| are (re)defined, unless the
% |preserveurlmacro| option is given.
%
% \begin{macrocode}
\if at preserveurlmacro\else\let\url\burl\let\urlalt\burlalt\fi
% \end{macrocode}
The command \url is actually a synonym of \burl, which may be most of
the issue, but \htmladdnormallink takes TWO arguments and it turns out
that this has to be accounted for properly.
I'm calling \url this way:
\url{http://www.cambridge.org/us/academic/subjects/physics/statistical-physics/theory-thermodynamics}
and my \htmladdnormallink looks like this:
\htmladdnormallink
{http://www.cambridge.org/us/academic/subjects/physics/statistical-physics/theory-thermodynamics}
{http://www.cambridge.org/us/academic/subjects/physics/statistical-physics/theory-thermodynamics}
HOWEVER the first argument can be anything one wants; the actual URL
used for the link is the second argument. I use this double form in
over 3000 bibtex references inside 'note = '. This way most of the
time the link shows the actual url in my references and I can fix it
if there are problems (like blanks or underscores). Putting '\\' into
the first argument does break the lines but I would have to adjust
each one and the bibtex entry would fail for different documents
since, for example, some documents have twocolumn which requires more
breaks than one column documents. So it needs to be an automatic wrap
method.
A solution would be to have breakurl add breaks to the first argument
of \htmladdnormallink. I was able to do this by adding one line to
breakurl.dtx. Here are the diffs between the original and the
modified breakurl.dtx:
408a409,410
> %tdszq Possible new code: replace '\url' with '\htmladdnormallink':
> % \DeclareRobustCommand{\burl}{\htmladdnormallink} % tdszq
705a708,709
> %tdszq additional code:
> \if at preserveurlmacro\else\let\htmladdnormallink\burl\let\urlalt\burlalt\fi
Unfortunately although this breaks the \htmladdnormallink lines, the
URL appears twice because of the method I'm using. A solution would
be to switch my \htmladdnormallink to \url and I'm investigating that
but with thousands of references I have to do it carefully.
In the meantime I suggest that breakurl be modified to break the first
argument and only use the second argument for the link.
Exmple code is in the zip file attached.
Tom
Thomas D. Schneider, Ph.D.
Senior Investigator
National Institutes of Health
National Cancer Institute
Center for Cancer Research
RNA Biology Laboratory
Biological Information Theory Group
Frederick, Maryland 21702-1201
schneidt at mail.nih.gov
https://alum.mit.edu/www/toms
-------------- next part --------------
A non-text attachment was scrubbed...
Name: breakurldemo.zip
Type: application/x-zip-compressed
Size: 29719 bytes
Desc: not available
URL: <https://tug.org/pipermail/texhax/attachments/20210829/bfa42490/attachment-0001.bin>
More information about the texhax
mailing list.