How to suppress the space before the colon, in French language?

Your problem is with the Babel shorthand for :. To disable this shorthand use \shorthandoff{:} inside your \begin{document}. It will not work when loaded in the preamble.

To re-enable the shorthand, use \shorthandon{:}.

\documentclass{article}
\usepackage[french]{babel}

\begin{document}
\shorthandoff{:}
Il est 20:20.

\shorthandon{:}
Il est 20:20.
\end{document}

enter image description here


I'm not sure this is the usual way to denote time in French; here's a workaround:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\edef\hc{\string:} % \hc prints a normal colon

\begin{document}
Il est 20\hc20.
\end{document}

Alternatively, use datetime:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{datetime}

\newcommand\heure[2]{\formattime{#1}{#2}{00}}

\begin{document}
Il est \heure{20}{20}
\end{document}

enter image description here


As suggested by PatrickT and mentioned in French internationalisation, override babel default spacing, \NoAutoSpacing is the easiest solution in modern (post-2011) TeX distributions.

\documentclass{article}
\usepackage[french]{babel}

\begin{document}
Il est {\NoAutoSpacing 20:20}.
\end{document}

Tags:

Babel

French