8

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?
2
  • 1
    @LianTzeLim This is a big overgeneralization. If you add \noautomath immediately after loading the package it should pose few problems.
    – Alan Munn
    Commented Apr 11, 2017 at 5:02
  • Sorry @AlanMunn, I take that back—gb4e did give me quite a bit of headache with most other packages I used.
    – imnothere
    Commented Apr 11, 2017 at 6:49

2 Answers 2

16

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}

output of code

4
  • Thanks so much for the help and solution! This is fascinating. Commented Apr 14, 2017 at 14:04
  • Thank you very much for this fix. It solved the same error I was getting (! LaTeX Error: Command \rmfamily invalid in math mode.) as well as a couple of weird formatting of \mathit{} symbols.
    – iNyar
    Commented Apr 17, 2020 at 23:02
  • "I'll re-notify Alexis Dimitriadis, the maintainer of gb4e." Did he answer? I'm still getting this in 2022 Commented May 20, 2022 at 23:56
  • 1
    @AzorAhai-him- I’ll try again. :)
    – Alan Munn
    Commented May 20, 2022 at 23:59
2

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}
1
  • And \noautomath doesn't help ....
    – cfr
    Commented Apr 11, 2017 at 2:16

You must log in to answer this question.

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