2

I'm writing French with typewriter font, and the default auto-spacing for punctuations provided by babel is a little unsatisfactory.

enter image description here

(the above one is in French mode, the bottom one is in English mode)

I need the space before punctuations to be exactly one whitespace. How can I modify this value?

Below is a MWE:

\documentclass{article}

\renewcommand{\familydefault}{\ttdefault}
\renewcommand{\rmdefault}{\ttdefault}
\raggedright

\usepackage[english,french]{babel}

\begin{document}

\selectlanguage{french}
Qu'est-ce que c'est ? C'est ...

\selectlanguage{english}
Qu'est-ce que c'est ? C'est ...

\end{document}
3
  • Please provide more information about what you've tried so far.
    – Mico
    Commented Feb 6, 2021 at 9:32
  • A small example to play with?
    – egreg
    Commented Feb 6, 2021 at 9:52
  • @egreg I just added a MWE. The one in English is the effect I'm looking for.
    – Jinwen
    Commented Feb 6, 2021 at 9:59

2 Answers 2

3

The code for ? removes a possible space before it and then adds \FBthinspace, which is defined as

\hskip 0.5\fontdimen2\font\relax

but what you want is the full \fontdimen2\font. On the other hand, the colon uses \FBcolonspace, which is defined as \space, so the full solution is to make the two macros do the same.

\documentclass{article}

\renewcommand{\familydefault}{\ttdefault}
\renewcommand{\rmdefault}{\ttdefault}
\raggedright

\usepackage[english,french]{babel}

\renewcommand{\FBthinspace}{\FBcolonspace}

\begin{document}

\selectlanguage{french}
Qu'est-ce que c'est ? C'est; c'est: c'est! ...

\selectlanguage{english}\frenchspacing
Qu'est-ce que c'est ? C'est ; c'est : c'est ! ...

\end{document}

enter image description here

In the English part used for comparison, I set \frenchspacing to avoid the extra space after punctuation being added.

2

Please note that babel-french does not modify the spacing before high punctuation when the font is declared as mono-spaced ("Typewriter").

In your example, you declare you are working with \rmfamily, that's why you get a thin space before the `?'. @egreg provided the right patch.

If you add \ttfamily after the \begin{document} in @egreg's example (removing the \renewcommand{\FBthinspace}), you will note that the space before '?' is what you want (inter-word space), but don't be surprised to get no space before ':' and '!' as none is present in the source code.

You must log in to answer this question.

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