[l2h] Tilde problem

jos jos at w3k.org
Tue Jan 3 20:57:15 CET 2006

Since we're on the topic of the classic tilde problem, I have not yet 
found a solution that works also for PDF links.  For years, I have 
been using "\~{}" within \htmladdnormallink{}{}, and that has worked 
fine for print and HTML, but for PDF links it fails since I started 
using, according to latex -v, pdfetex 3.14592-1.21a-2.2 (which came 
with Fedora Core 4).  I believe this version of pdfetex came with the 
recent tetex 3.0 package, and that it incorporates hyperref 
functionality.  I first generate PostScript which is then converted 
to PDF by ps2pdf.  (I can't generate PDF directly because of my 
PostScript figures.)  In the PDF link, "\~{}" comes out as "~%7b%7d", 
which doesn't work as a link.  Leaving out "{}" results in a working 
PDF link, but no '~' is printed in the footnote. To make PDF links 
work, I must leave out '{}' in the second argument to 
\htmladdnormallinkfoot{}{}, but then the footnote is printed without 
a '~', whether it is escaped with '\' or not.  Apparently, \url{} is 
not allowed in the second argument to \htmladdnormallinkfoot{}{} 
because it is a "moving argument".

I notice that in the PostScript file, each link is included verbatim 
(escapes and all) in a context that knows it is a link (based on the 
associated function names /URI and /Link).  My guess is that ps2pdf 
(really ps2pdfwr, which uses ghostscript for the conversion) needs 
attention regarding link translation.

If there is a workaround in the LaTeX source, please let me know what it is!

Below is my test file in case anyone wants to try something out quickly:


  \item This
\htmladdnormallinkfoot{link}{http://ccrma.stanford.edu/~jos/} uses
tilde as if it would simply work.  The link works in PDF and HTML, but
it is printed in PDF with a space in place of tilde.

  \item This
uses the standard \verb!\~{}! construct.  The PDF link fails, though it
prints ok.  The HTML link works.

  \item This
uses \verb!\~! only.  The PDF link works, but it prints with the
tilde omitted (no space).  The HTML link fails (tilde omitted).


At 10:24 AM 1/3/2006, Bob van der Poel wrote:

>Robin Fairbairns wrote:
>>>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
>>>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?
>>url.sty provides "sensible" breaks that are useful in long urls.
>>since it postdates the invention of l2h, there's never been an
>>adequate way of dealing with it in l2h.
>>if you want to have typeset urls in your documents, i would recommend
>>having latex-only and html-only sections, load url in a latex-only
>>section and do "proper" urls in that, and do the old-fashioned
>>non-breakable \texttt-style urls in the html sections.
>>otoh, if you don't need anything more complicated than your ~/foo
>>things, you might as well forget url.sty altogether.
>Thanks for this.
>I have just taken the easy way out and am using a macroized texttt{} 
>to print my paths in the document. This now works fine in the l2h 
>and latex version. Of course, I did have to fix the tildes, but that 
>was not a big deal.
>Interesting is that I have some tildes in urls, like 
>\url{http://mypage.uniserve.com/~bvdp} and the tilde in this case 
>prints find in both l2h and latex versions. I'm no tex-expert, but 
>looking at url.sty I was assuming that \path{} and \url{} were 
>pretty much the same.
>Oh, one other interesting difference is that with the url version of 
>\path{} I get a larger "~" centered (vertically) on the line; with 
>\textt{} I get a smaller, raised "~". Why the difference?
>I don't have any really long paths so my hack seems to work fine. 
>But, it would be nice if url.sty worked with both versions. Maybe 
>when you have absolutely nothing else to do :)
>Bob van der Poel ** Wynndel, British Columbia, CANADA **
>EMAIL: bvdp at uniserve.com
>WWW:   http://mypage.uniserve.com/~bvdp
>latex2html mailing list
>latex2html at tug.org

More information about the latex2html mailing list