GeneralWhat about French accents in URL ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What about French accents in URL ?

Post by Cham »

There are some URL with French accents that I want to use, as clickable links in the PDF file. I'm currently using the hyperref package with the unicode option, and my LaTeX file is also using the following packages in its preamble :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
Is there a way to make clickable the URLs with French accents ? Currently, they are correctly shown in the PDF file but they can't be clicked (the link doesn't react to the mouse click).
Last edited by Cham on Sat Jul 02, 2011 5:46 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

paul
Posts: 49
Joined: Thu Apr 08, 2010 5:56 am

What about French accents in URL ?

Post by paul »

Cham wrote:There are some URL with French accents that I want to use, as clickable links in the PDF file. I'm currently using the hyperref package with the unicode option, and my LaTeX file is also using the following packages in its preamble :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
Is there a way to make clickable the URLs with French accents ? Currently, they are correctly shown in the PDF file but they can't be clicked (the link doesn't react to the mouse click).
Well, you can't have accented characters in URLs, only ASCII. The rest of Unicode can be encoded into ASCII according to some weird "IDNA" scheme, but (a) you can only have those names in certain top-level domains, and (b) LaTeX doesn't have any way to do the encoding automatically [AFAIK].

Use \href{IDNA-URL}{URL-as-you-want-it-to-appear}
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: What about French accents in URL ?

Post by Cham »

Thanks for the reply.

This confirms what I thought.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What about French accents in URL ?

Post by Cham »

Well, what would you do if, for example, you want to direct the reader to a site like this one :

http://en.wikipedia.org/wiki/Erwin_Schrödinger

I know there's the non-ascii "ö" in there, but IFAIK, this is a working and legitimate link (EDIT : hmmm, maybe not, since the link is truncated at the "ö"). There really is no solution in this case ?

And why the next one is actually working with hyperref (but not here) ? There's an "é" in there !

http://en.wikipedia.org/wiki/Henri_Poincaré
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

What about French accents in URL ?

Post by shadgrind »

This may not be what you're looking for, but it worked for me:

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[unicode]{hyperref}
\usepackage{url}
\begin{document}
\tableofcontents
\chapter{Schr\"{o}dinger}
A URL with an umlaut: \url{http://en.wikipedia.org/wiki/Erwin_Schr\"{o}dinger}
\chapter{Poincar\'{e}}
A URL with an accent: \url{http://en.wikipedia.org/wiki/Henri_Poincar\'{e}}
\end{document}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: What about French accents in URL ?

Post by Cham »

The Schrödinger link is non-clickable. That's the problem I'm concerned with.
Is it clickable for you ?

The Poincaré link is clickable, though, even if there's an "é" in it.
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

What about French accents in URL ?

Post by shadgrind »

Cham wrote:The Schrödinger link is non-clickable. That's the problem I'm concerned with.
Is it clickable for you ?
Yes, it's clickable for me, both as the chapter name in the table of contents and in the URL to the wikipedia page. I'm using Acrobat Reader to view the pdf.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What about French accents in URL ?

Post by Cham »

This is strange.

I'm using Preview (in OS X), and the Poincaré URL link is working, while the Schrödinger URL link isn't (it's clickable but doesn't do anything). What the ... ?
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Re: What about French accents in URL ?

Post by shadgrind »

Sounds like a problem with the Preview application in OS X. In Linux using three different PDF viewers - Acrobat Reader, Evince, Foxit Reader - the Schrödinger links are both clickable and perform the desired action. Try one of those PDF viewers and see if the problem persists.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What about French accents in URL ?

Post by Cham »

I just discovered a general solution to my problem. Now, I can use any accents or special characters in an URL, and the URL link is clickable (i.e. fully functionnal) : I just need to use the \href command with UNICODE encoding. Here's an example :

Code: Select all

\href{http://fr.wikipedia.org/wiki/Vall\%C3\%A9e_sacr\%C3\%A9e_des_Incas}{\tt http://fr.wikipedia.org/wiki/Vallée\_sacrée\_des\_Incas}
In this case, the French letter "é" is replaced by its UNICODE translation %C3%A9. In LaTeX, we just need to add "\" before each "%", in the URL code line.

In OS X, there's a system tool which gives the UNICODE for any character, so it's very easy to set up. :)
Post Reply