4

Here is my minimal code:

\documentclass[12pt]{memoir}
\usepackage{polyglossia}
\setdefaultlanguage{french}

\begin{document}
Bonjour tout le monde. Si je vais au bout de la ligne, je vais avoir cela : non !
\end{document}

Here is the result: enter image description here

How can I prevent the line break just before ":"?

12

There is a bug in gloss-french (or more precisely it hasn't been updated to the new xetex yet). The space/boundary has in the newer xetex versions another class. This avoids the break:

\documentclass[12pt]{memoir}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\makeatletter
\XeTeXinterchartoks 4095 \french@punctthin = {\xpg@unskip\nobreak\thinspace}%
\XeTeXinterchartoks 4095 \french@punctthick = {\xpg@unskip\nobreakspace}%
\makeatother

\begin{document}
Bonjour tout le monde. Si je vais au bout de la ligne, je vais avoir cela : non !
\end{document}

A patch that would allow you to run the document with luatex too would be:

\documentclass[12pt]{memoir}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\usepackage{etoolbox}

\makeatletter
\patchcmd\french@punctuation{255}{4095}{}{}
\patchcmd\french@punctuation{255}{4095}{}{}
\makeatother

\begin{document}
Bonjour tout le monde. Si je vais au bout de la ligne, je vais avoir cela : non !
\end{document}

Beside this you don't have to add the space in the input as the french module will do it for you

\documentclass[12pt]{memoir}
\usepackage{polyglossia}
\setdefaultlanguage{french}

\begin{document}
Bonjour tout le monde. Si je vais au bout de la ligne, je vais avoir cela: non!
\end{document}

(Imho if you also write in other languages it is a good idea to get used to an input without spaces as it will give the wrong output e.g. in an english or german context.)

enter image description here

  • 1
    @cjorssen: Do you mean that you have already written a lot of source code writing things like cela : instead of cela:? – GuM Sep 22 '16 at 17:20
  • @cjorssen: I edited the answer. Actually there is a bug in gloss-french. – Ulrike Fischer Sep 22 '16 at 17:24
  • Thanks. So it affects only xetex? – cjorssen Sep 22 '16 at 18:47
  • @cjorssen: Yes together with polyglossia. babel/frenchb has already adapted the code. – Ulrike Fischer Sep 22 '16 at 19:03
  • 1
    I adapted the answer. The bug has already been reported: github.com/reutenauer/polyglossia/issues/145. Besides this: Imho the french module of babel is much more sophisticated then the one of polyglossia. – Ulrike Fischer Sep 23 '16 at 7:55

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.