# Can't compile XeLaTeX document with biblatex and gb4e together

The following document will not compile (using xelatex, biber) if the package gb4e is activated. If you comment out the gb4e package it works fine:

\documentclass{article}
\usepackage{fontspec}
\setromanfont{Times New Roman}
% \usepackage{gb4e} % <-- FAILS WITH THIS PACKAGE ACTIVATED

\usepackage[nopar]{lipsum} % for dummy text
\usepackage[american]{babel}
\usepackage[authordate,isbn=false,backend=biber]{biblatex-chicago}

\begin{filecontents}{\jobname.bib}
@book{Saussure1995,
Author = {Ferdinand de Saussure},
Origyear = {1916},
Publisher = {Payot},
Title = {Cours de Linguistique Générale},
Year = {1995}}
\end{filecontents}

\begin{document}
\section*{Les Présentations}
\lipsum[1] \autocite{Saussure1995}
\printbibliography
\end{document}


Any help would be greatly appreciated.

-
Welcome to TeX.sx! It seems that loading gb4e after biblatex fixes the problem, at least with the MWE. –  egreg Mar 7 '13 at 13:50
Thanks, the oldest trick in the book! Frustratingly however although it works in my MWE, it doesn't help my real document. I'll look at it some more. –  Michael Dunn Mar 7 '13 at 14:08
That's what I feared. You can try putting \noautomath just after loading gb4e, which disables the special usage of _ that, I believe, is responsible for the incompatibility. –  egreg Mar 7 '13 at 14:20
Amazing, that worked! I can reproduce the error in the MWE if I use underscores in labels of the references, e.g. Saussure_1916. –  Michael Dunn Mar 7 '13 at 14:23

In the gb4e.sty package one finds this comment:

    %  This file allows _ and ^ to be used in ordinary text, hence must be
%  loaded AFTER any file that uses them in their TeX meaning. Hence
%  cgloss(n).sty is loaded early in this file.  This feature is known to
%  cause some problems with other packages, but is maintained for backward
%  compatibility. If you have problems, you can try disabling it by


The definition it gives of the active underscore is

% \automath     Make _ and ^ work outside math mode
% \noautomath   Restore normal sub/superscript behavior

{ % Temporarily change catcodes
\catcode\_=\active
\catcode\^=\active

\global\def\automath{%
\catcode\_=\active
\catcode\^=\active
\def_##1{\gb@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}%
\def^##1{\gb@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}}
}
\def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}}
% Restore default catcodes for ^, _
\def\noautomath{\catcode\_=8 \catcode\^=7 }


which is, in my opinion, bad. Indeed the package authors thought it better to provide a way for disabling it. In any case, when \automath is enabled (which it is by default), the underscore cannot be used in labels.

So my best advice is doing

\usepackage{gb4e}
\noautomath

-