6

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?

6

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

  • Beaten me for a few seconds... – karlkoeller Feb 4 '15 at 11:51
  • @karlkoeller The train is on schedule. ;-) – egreg Feb 4 '15 at 11:53
  • As always... (yours). :-) – karlkoeller Feb 4 '15 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 '15 at 12:16

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.