[texhax] Problem with \href and german umlauts

Matthew Leingang leingang at math.harvard.edu
Thu Mar 6 14:04:55 CET 2008


On Mar 5, 2008, at 2:36 PM, Lars Brücher wrote:

> Hello there,
>
> creating a pdf-file with LaTeX, I'm trying to use the \href{}  
> command to link to a german wikipedia article (the english pendant  
> is http://en.wikipedia.org/wiki/Macroglossum_stellatarum).
> I use the command as follows:
>
> #code
>
> \href{http://de.wikipedia.org/wiki/Taubenschwänzchen}{http:// 
> de.wikipedia.org/wiki/Taubenschwänzchen}
>
> #/code
>
> I think, the hyperref-package denies the use of german "Umlaute"  
> such as ä in URLs, but how can I refer to that page? The generated  
> hyperlink-address is this:
>
> #code
>
> http://de.wikipedia.org/wiki/Taubenschw\protect\unhbox\voidb@x 
> \bgroup\U at D1ex{\setbox\
> z@\hbox{\char127}\dimen at - .45ex\advance\dimen@\ht\z@}\accent127 
> \fontdimen5\font\U at Da\
> egroupnzchen
>
> #/code
>
> Is there any possibility to realize that?

Dear Lars,

On my machine if I go to that URL it's rewritten to a more ASCII- 
friendly

     http://de.wikipedia.org/wiki/Taubenschw%C3%A4nzchen

So you can use that as the destination of your hyperlink:

     \href{http://de.wikipedia.org/wiki/Taubenschw%C3%A4nzchen}
	 {http://de.wikipedia.org/wiki/Taubenschw\"anzchen}

The % will be interpreted the "right" way (i.e., not as TeX comments)  
by TeX but maybe not your text editor's syntax coloring mechanism.   
So that's kind of annoying.  But it does create a link to the place  
you want to go, with a URL written the way you want to see it.

Incidentally, if you want to insert a clickable URL into your  
document, often times all you need is the url package.  Then

     \url{http://de.wikipedia.org/wiki/Hauptseite}

will create a link with destination URL and link text equal to the  
same thing.  It also sets the URL text in monospace font, underlined,  
so it looks clickable.  It even interprets ~, _ and other characters  
correctly so they're not converted to nonbreaking spaces and subscripts.

It doesn't seem to help with your umlauts, but I think that's the  
fault of LaTeX for not wanting non-ASCII characters.  XeTeX is  
designed to work with unicode, but I don't know if you want to switch  
your TeX program just to get some URLs quicker. :-)

Grüße aus der Vereinigten Staaten,
Matt

--
Matthew Leingang
Preceptor in Mathematics
Harvard University

http://www.math.harvard.edu/~leingang/vCard.vcf





More information about the texhax mailing list