9

When writting mathematics in a french document, you should use the semicolon instead of the comma to separate the coordinate of a vector or a point (for example). The problem is that in math mode, even with \usepackage[french]{babel}, the spacing around the semicolon is wrong (it lacks a space just before it) and you must add ~ or \,.

How to get the semicolon working correctly in math mode?

2

1 Answer 1

9

You may want to make the semicolon into a binary operator, if you always use the semicolon in math in those contexts.

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

\AtBeginDocument{\mathcode`\;=\numexpr\mathcode`\;-\string"4000\relax}

\begin{document}

Point-virgule; une formule $(a;b)$.

\end{document}

enter image description here

A different approach, which could be a feature request to the maintainers of babel-french, is to modify how the semicolon works when found in math mode.

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

\makeatletter
\declare@shorthand{french}{;}{%
  \ifhmode
    \ifdim\lastskip>\z@
      \unskip\penalty\@M\FBthinspace
    \else
      \FDP@thinspace
    \fi
  \else
    \ifmmode
      \mskip\thinmuskip
    \fi
  \fi
  \string;}
\makeatother


\begin{document}

Point-virgule; une formule $(a;b)$.

\end{document}

enter image description here

5
  • 1
    Beaten me for a few seconds... Feb 4, 2015 at 11:51
  • 1
    @karlkoeller The train is on schedule. ;-)
    – egreg
    Feb 4, 2015 at 11:53
  • 1
    As always... (yours). :-) Feb 4, 2015 at 11:54
  • The fist solution works well and it’s very short, however the space behind the semicolon in math mode is larger than in text mode (or at least it seems to.) Sadly, the second solutions didn’t work.
    – Zoxume
    Feb 4, 2015 at 12:16
  • First solution breaks with Polyglossia and Babel when using LuaLaTeX, but works when using XeLaTeX engine. The error returned is Invalid math code during > 0x8000 mathcode fallback. Any idea to fix this? Feb 6, 2022 at 17:01

You must log in to answer this question.

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