Incompatibility between siunitx and gb4e

It looks like the siunitx package and the gb4e package are in conflict.

More specifically, the following code would not run:

\documentclass[11pt]{article}
\usepackage{gb4e}
\def\fg{}
\usepackage{siunitx}
\begin{document}
yo

\SI{30}{\degreeCelsius}
\end{document}


Returning the error

Command \rmfamily invalid in math mode

Now, I know that the packages linguex and siunitx are in conflict, and I know how to resolve that: load linguex first, (re)define \fg (the command in conflict) to null, and then load siunitx, i.e.

\usepackage{linguex}
\def\fg{}
\usepackage{siunitx}


But this does not resolve the problem here.

The code at the top would work however if we do not use the command \SI{}{} at all. i.e. if we remove the line

\SI{30}{\degreeCelsius}


then the code at the top would work.

(Note: Even if we were to use just

\SI{30}{degreeCelsius}


the code would still not work.)

• What other commands might be in conflict?
• Or is there any other reason the two are in conflict?
• @LianTzeLim This is a big overgeneralization. If you add \noautomath immediately after loading the package it should pose few problems. – Alan Munn Apr 11 '17 at 5:02
• Sorry @AlanMunn, I take that back—gb4e did give me quite a bit of headache with most other packages I used. – LianTze Lim Apr 11 '17 at 6:49

The cause of the problem

The redefinition of ^ and _ that gb4e does has nothing to do with this problem, because (as @cfr notes) it isn't solved by \noautomath. The problem is some code in the package that checks for the presence of a very old LaTeX kernel.

Changes to the current LaTeX kernel that happened a few years ago have caused this code to do the opposite of what was intended. I thought this bug had been fixed, but apparently it hasn't. I'll re-notify Alexis Dimitriadis, the maintainer of gb4e.

Workaround

Before you load the gb4e package, add the following code:

\makeatletter
\def\new@fontshape{}
\makeatother


It's also a good idea to load gb4e after siunitx. If you don't you will need to add \noautomath immediately after loading gb4e.

Here's a complete example:

\documentclass[11pt]{article}
\makeatletter
\def\new@fontshape{}
\makeatother

\usepackage{siunitx}
\usepackage{gb4e}

\begin{document}

\SI{30}{\degreeCelsius}
\end{document}


• Thanks so much for the help and solution! This is fascinating. – Rethliopuks Apr 14 '17 at 14:04

Package gb4e redefines ^, so you need to use \textsuperscript instead of ^ for degrees. The way to make siunitx to do this is to select text mode for the units. Also, in this case you do not need to redefine \fg unless you want to do it for other purposes.

This works:

\documentclass[11pt]{article}
\usepackage[mode=text]{siunitx}
\usepackage{gb4e}

\begin{document}
yo

\SI{30}{\degreeCelsius}
\end{document}

• And \noautomath doesn't help .... – cfr Apr 11 '17 at 2:16