# [l2h] newbie, problem with \url + lyx

Ross Moore Ross Moore <ross@ics.mq.edu.au>
Wed, 13 Sep 2000 09:58:44 +1100 (EST)

>
> >>Date: Wed, 13 Sep 2000 02:52:54 +0700 (JAVT)
> >>From: Arie Zanahar <arie@nawala.com>
> >>To: Ross Moore <ross@ics.mq.edu.au>
> >>cc: latex2html@tug.org
> >>Subject: Re: [l2h] newbie, problem with \url + lyx
> >>
> >>When I try, I use lyx to convert it to .tex. Then I use latex2html, it
> >>makes my \url isn't convert to hyper-links. So although I add
> >>\url{http://www.blah.com} will not be a hyper-links. Do you have any
> >>solution to fix it ?
>
> Seems to be rather a Lyx question than a latex2html one, but...
>
> Lyx produces its own encodeing for an url as:
> \htmlurl[anchor]{URL}

This is very bad, as \htmlurl  is defined also
in the html.sty package, required for LaTeX2HTML.
(as are many other commands with names starting \html....).

Lyx should use the name \lyxurl or something else that is distinct to
its own name of Lyx.

> Typographically, it prints anchor as is and URL with the url.sty
> wrapping to avoid problems with long words.

Then to sort out the mess caused by the name clash, you will need
conditional code like the following in the document preamble:

%begin{latexonly}
\let\lyxurl\htmlurl  % save a pointer to lyx's \htmlurl
%end{latexonly}
\usepackage{html}    % ensure that html.sty is loaded
\begin{htmlonly}
\renewcommand{\htmlurl}[2][]{%
\end{htmlonly}
%begin{latexonly}
\let\htmlurl\lyxurl  % recover the pointer to lyx's \htmlurl
%end{latexonly}

Now you should be able to use \htmlurl
for all the hyperlinks, both with LyX and with LaTeX2HTML.

However...

... the optional argument is now *mandatory*.
LaTeX2HTML may not produce a link for  \htmlurl{<URL>}
without any anchor text.

> So everything is there to produce a good hypertext, but the
>
> So two ways to deal with it:
>  - write e translator for \htmlurl to produce <A HREF="URL">anchor</A>

The above code effectively does this, by converting Lyx's use
of \htmlurl into a form that LaTeX2HTML already knows how to handle.
Also it opens up the full power of  html.sty  for markup
intended mainly for the HTML version of a document.

>  - process the lyx file to create the right code using html.sty
>
> I have here a workaround using the second approach, which puts
> a lot of ERT (i.e. plain (La)TeX commands) in the original LyX file.

Certainly it is good to use markup defined from html.sty
so that there are not too many (perhaps incompatible) styles
being used to markup URLs in LaTeX documents.

An alternative approach is to define your own command; e.g. \myurl
using conditional definitions:

\usepackage{html}
\begin{htmlonly}
% perhaps load HTML-specific definitions from a .tex file
% \input myHTMLdefs.tex
%
% or define \myurl here
%
\end{htmlonly}
%begin{latexonly}
% perhaps load Lyx-specific definitions from a .sty file
% \usepackage{myLyXdefs}
%
% or define \myurl here
\newcommand{\myurl}[2]{\lyxurl[#1]{#2}}
%
%end{latexonly}

(assuming \lyxurl is a pointer to the real macro expansion).

> Hope this helps.

And this too.

Ross Moore

>
> --
> Jean-Pierre
>
>