14

I use UTF-8 encoding to type a document in French, with the following definitions for guillemets:

\DeclareUnicodeCharacter{AB}{\og}
\DeclareUnicodeCharacter{BB}{\fg\xspace}

and the Babel package:

\usepackage[francais]{babel}

However, when I type a text like ceci cela «~quoted~» ceci cela, the spacing is wrong around the opening guillemet:

enter image description here

Notice that the space before the opening guillemet is too small, and the spacing after is too large. The closing guillemet has correct spacing. How could I fix that?

1
  • I remember sending a bug report to the (active) developer of the french babel package earlier this year, regarding this particular issue when using XeLaTeX. He issued a corrective patch within days, which is available for download here. (Note: I am unsure whether it solves your problem, but someone might be interested in this anyway.)
    – ienissei
    Sep 11, 2012 at 8:09

1 Answer 1

18

The spacing is already inserted by \og and \fg, so you shouldn't type the ~. You can consider changing the definition of the Unicode character as

\DeclareUnicodeCharacter{AB}{\og\ignorespaces}
\DeclareUnicodeCharacter{BB}{\unskip\fg}

so that inputting

Ces simulations «directes» sont ainsi

Ces simulations « directes » sont ainsi

will be equivalent.

enter image description here

Notice that \xspace does nothing.

If you insist to type «~directes~», then the definition for the open guillemets character could be

\makeatletter
\DeclareUnicodeCharacter{AB}{%
  \og\@ifnextchar~{\@gobble}{}}
\makeatother

Say what you want, but I find this spacing awful. ;-)

4
  • The reason I type the space is that I am so used to it in all other environments that I cannot refrain from typing it when I write in TeX… And if I continue typing the ~, \ignorespaces isn't enough, I still get wrong spacing.
    – F'x
    Sep 10, 2012 at 23:26
  • @F'x With that definition just don't use ~. Since you probably use the T1 encoding, you can also write <<~directes~>> but with a slight difference in spacing (\og and \fg are designed for removing the little space in excess).
    – egreg
    Sep 10, 2012 at 23:30
  • I understand, but not using ~ isn't a solution for me. I'm sure LaTeX has a way of accomodating my particular need, rather than me having to do the extra work
    – F'x
    Sep 10, 2012 at 23:32
  • @F'x I've added an alternative definition that allows «~.
    – egreg
    Sep 10, 2012 at 23:35

You must log in to answer this question.

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