[l2h] Tilde problem

Igor Peshansky pechtcha at cs.nyu.edu
Tue Jan 3 06:48:45 CET 2006


Top-post reformatted...

On Mon, 2 Jan 2006, Bob van der Poel wrote:

> Les Richardson wrote:
>
> > > Hi. I am using the url package and have some lines like:
> > >
> > > 	\path{~/foo}
> > >
> > > Without looking at the source for url I am assuming that \path is a
> > > special form of verbatim ... whatever, this works fine for latex.
> > >
> > > But, when I use latex2html the ~ disappears. In the manual for
> > > latex2html it does state that you need to use ~{}, but that inserts a
> > > visable {} in the latex output; and in latex2html both the ~ and the {}
> > > disappear.

While I'm not able to find this in the manual at the moment, I think it
recommends using \~{}, not ~{}...  But, according to url.sty, \path, as
well as most other url commands, is indeed a form of verbatim, so this
won't work anyway.

> > > Hmm, looking further I see that I already changed the def of \path for
> > > latex2html to:
> > >
> > > 	\newcommand{\path}[1]{\texttt{#1}}
> > >
> > > So, that is wrong ... I'm lost just now. Suggestions?
> >
> > The tilde is a non-breaking space in TeX... can't one just escape it (\~)
> > and have it function normally?
>
> Thanks for the pointer, Les. After smacking the side of head a few times
> the light is slowly coming on :)
>
> Yes, a tilde is a non-breaking space. So, with
>
> \newcommand{\path}[1]{\texttt{#1}}
>
> I can do something like \path{\~{}/foo} and it works just fine. But, if
> I use the \path{} from the url.sty file which provides some line
> breaking feature (?? I really have to go check why I'm using this I
> think ??) then "\" and "{}"s are printed verbatim. So, I guess I have to
> use the same macro for both latex and latex2html.
>
> Anyone have a simple solution?

Well, you can follow Robin Fairbairns' advice and not use the url package,
but if you really do need the line-breaking features in the LaTeX version,
try adding this[*] to your .latex2html-init (after removing the
re-definition of \path from the preamble):

sub do_cmd_path {
    local($_) = @_;
    local($text);
    $text = &missing_braces unless (
        (s/$next_pair_pr_rx/$text = $2;''/e)
        ||(s/$next_pair_rx/$text = $2;''/e));
    $text =~ s,;SPMnbsp;,\~,g;
    $text . $_;
};

HTH,
	Igor
[*] Untested, some perl hacking may be needed to get this working.
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha at cs.nyu.edu | igor at watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"



More information about the latex2html mailing list