25

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

3

3 Answers 3

14

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
  • 5
    I think the usual way to denote time in French is 20h20.
    – giordano
    Jan 20, 2014 at 17:33
  • 1
    @giordano I also suspect “20:20” is not common.
    – egreg
    Jan 20, 2014 at 17:35
  • 2
    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, 2014 at 10:56
29

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

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

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}
3
  • Could you please add a MWE?
    – Colas
    Aug 12, 2016 at 10:43
  • edit: added a MWE Sep 6, 2017 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, 2018 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .