21

I would like to suppress the space before the colon, when using [french]babel. I only want to change this locally (that is not everywhere in the document, but just at some place).

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

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

enter image description here

13

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

  • 3
    I think the usual way to denote time in French is 20h20. – giordano Jan 20 '14 at 17:33
  • 1
    @giordano I also suspect “20:20” is not common. – egreg Jan 20 '14 at 17:35
  • 1
    It is true, but in some contexts, 20:20 is better. For instance, if you say : "The digital alarm clock was displaying 20:20". – Colas Jan 21 '14 at 10:56
25

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

  • Good suggestion, but doesn't work with XeLaTeX ... the log file suggests using \NoAutoSpacing instead. – PatrickT Apr 27 '16 at 20:35
10

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}
  • Could you please add a MWE? – Colas Aug 12 '16 at 10:43
  • edit: added a MWE – devernay Sep 6 '17 at 7:17
  • See also the documentation of Babel French daniel.flipo.free.fr/frenchb/frenchb-doc.pdf This command is necessary for example for natbib bibliography style plainnat (and \shorthandoff does not work in that case). – yannis Sep 22 '18 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.