无法使用 biblatex 和 gb4e 一起编译 XeLaTeX 文档

无法使用 biblatex 和 gb4e 一起编译 XeLaTeX 文档

如果激活了该包,则以下文档将无法编译(使用xelatex, ) 。如果您注释掉该包,它将正常工作:bibergb4egb4e

\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}
\addbibresource{\jobname.bib}

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

任何帮助将不胜感激。

答案1

gb4e.sty包中可以发现这样的评论:

    %  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
    %  placing the command \noautomath immediately after loading the gb4e package.
    %  [Added 2009/12/28]

它给出的活动下划线的定义是

% \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 }

在我看来,这很糟糕。事实上,软件包作者认为最好提供一种禁用它的方法。无论如何,当\automath启用时(默认情况下),下划线不能用于标签。

所以我最好的建议是

\usepackage{gb4e}
\noautomath

相关内容