hyperref
hyperref copied to clipboard
Problem with \href and active characters of babel-french
Hello!
With that example:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[12pt,french,a4paper,twoside]{article} \usepackage[T1]{fontenc} \usepackage{babel} \usepackage{lmodern} \frenchsetup{og=«,fg=»} \usepackage{hyperref} \hypersetup{colorlinks,linkcolor=blue,urlcolor=blue} \usepackage{xcolor} \begin{document} \href{http://url}{Test: bla bla} \textcolor{red}{incorrect} (Test: bla bla)
\href{http://url}{Test; bla bla} \textcolor{red}{incorrect} (Test; bla bla)
\href{http://url}{Test! bla bla} \textcolor{red}{incorrect} (Test! bla bla)
\href{http://url}{Test? bla bla} \textcolor{red}{incorrect} (Test? bla bla)
\end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
you can see than the espacement between Test and : or ; or ! or ? is not correct (in French, of course). Into the parens, the espacement is correct.
Best regards.
François
Yes, that is known. There is a rather long discussion about different variants here (the behaviour depends on the engine and also on the first argument) https://tex.stackexchange.com/questions/394208/how-to-get-suppress-french-spacing-before-punctuation-in-href
Basically you have to switch a boolean to reactivated the active chars:
\documentclass[12pt,french,a4paper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{lmodern}
\frenchsetup{og=«,fg=»}
\usepackage{hyperref}
\hypersetup{colorlinks,linkcolor=blue,urlcolor=blue}
\usepackage{xcolor}
\begin{document}
\href{http://url}{Test: bla bla} \textcolor{red}{incorrect} (Test: bla bla)
\href{http://url}{\csname @safe@activesfalse\endcsname Test: bla bla}
\end{document}
I'm not sure if it would be a good idea to add this by default. It could change existing documents not expecting active chars in this place.
OK, thank you Ulrike.
I've created a new command \Href:
\newcommand{\Href}[3][]{\href[#1]{#2}{\csname @safe@activesfalse\endcsname#3}}
and it makes the job.
It's maybe a solution?