[Tex/LaTex] Extra } or forgotten $ with biblatex and biber

biberbiblatexerrors

I'm relatively baffled by the behavior of the following MWE. As far as I can tell, there is nothing wrong with the .bib entries. However, trying to compile this document (biblatex v3.3 and biber v2.4) results in the following error:

! Extra }, or forgotten $.
<recently read> }

l.42 

? 

If you make the relevant changes to use natbib instead, the MWE compiles just fine.

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = arara
% arara: lualatex: { synctex: no }
% arara: biber
% arara: lualatex: { synctex: yes }

\begin{filecontents*}{\jobname.bib}
@article{belletti1988,
    Author = {Belletti, Adriana and Rizzi, Luigi},
    Doi = {10.1007/BF00133902},
    Journal = {Natural Language \& Linguistic Theory},
    Month = {August},
    Number = {3},
    Pages = {291--352},
    Title = {Psych-Verbs and $\theta$-Theory},
    Volume = {6},
    Year = {1988}}
\end{filecontents*}

\documentclass{article}

\usepackage[american]{babel} 

\usepackage{csquotes} 

\usepackage
  [
    style=apa,
    backend=biber
  ]
  {biblatex}

\DeclareLanguageMapping{american}{american-apa}

\addbibresource{\jobname.bib}

\begin{document}

\textcite{belletti1988}

\printbibliography

\end{document}

The resulting .bbl file looks fine, as far as I can tell, which leads me to think it's a problem with biblatex, but I'm really not sure. Here's the resulting .bbl file:

% $ biblatex auxiliary file $
% $ biblatex bbl format version 2.6 $
% Do not modify the above lines!
%
% This is an auxiliary file used by the 'biblatex' package.
% This file may safely be deleted. It will be recreated by
% biber as required.
%
\begingroup
\makeatletter
\@ifundefined{ver@biblatex.sty}
  {\@latex@error
     {Missing 'biblatex' package}
     {The bibliography requires the 'biblatex' package.}
      \aftergroup\endinput}
  {}
\endgroup


\refsection{0}
  \sortlist[entry]{apa/global}
    \entry{belletti1988}{article}{}
      \name{author}{2}{}{%
        {{uniquename=0,hash=2c14abe3cc130a5e92d3a9be58ce2a7a}{%
           family={Belletti},
           family_i={B\bibinitperiod},
           given={Adriana},
           given_i={A\bibinitperiod}}}%
        {{uniquename=0,hash=3a9997806c8053ebfb136c367b21844b}{%
           family={Rizzi},
           family_i={R\bibinitperiod},
           given={Luigi},
           given_i={L\bibinitperiod}}}%
      }
      \strng{namehash}{fdc76b94e4c47018bee5a5282eb818bb}
      \strng{fullhash}{fdc76b94e4c47018bee5a5282eb818bb}
      \field{sortinit}{B}
      \field{sortinithash}{4ecbea03efd0532989d3836d1a048c32}
      \field{labelyear}{1988}
      \field{labelmonth}{08}
      \field{datelabelsource}{year}
      \field{labelnamesource}{author}
      \field{labeltitlesource}{title}
      \field{journaltitle}{Natural Language \& Linguistic Theory}
      \field{month}{08}
      \field{number}{3}
      \field{title}{Psych-Verbs and $\theta$-Theory}
      \field{volume}{6}
      \field{year}{1988}
      \field{pages}{291\bibrangedash 352}
      \range{pages}{62}
      \verb{doi}
      \verb 10.1007/BF00133902
      \endverb
    \endentry
  \endsortlist
\endrefsection
\endinput

Most interestingly, if you wrap $\theta$ in braces, everything works fine, e.g.:

    Title = {Psych-Verbs and {$\theta$}-Theory},

As far as I know, this is not something that has ever been required with biblatex and Biber. Am I incorrect, or is this a bug?

Best Answer

The definition of \MakeSentenceCase needs to allow for math mode. A possible fix is

\makeatletter
\def\blx@mksc@init{%
  \blx@mkcp@init
  \def\blx@mkcp@nil{\noexpand\blx@mkcp@nil\noexpand}%
  \def\i{\blx@mkcp@nil\i}\def\j{\blx@mkcp@nil\j}%
  \def\do##1{%
    \ifx##1\relax
    \else
      \def##1{\blx@mkcp@nil##1}%
      \expandafter\do
    \fi}%
  \expandafter\do\@uclclist\relax
  \let\(=$\let\)=$}

\def\blx@mksc@eval{%
  \ifx\@let@token\blx@mksc@end
    \expandafter\blx@mksc@end
  \fi
  \ifx\@let@token\bgroup
    \expandafter\blx@mksc@group
  \fi
  \ifx\@let@token\@sptoken
    \expandafter\blx@mksc@space
  \fi
  \ifx\@let@token\blx@mkcp@nil
    \expandafter\blx@mksc@getone
  \fi
  \ifx\@let@token\blx@mkcp@iec
    \expandafter\blx@mksc@getiec
  \fi
  \ifx\@let@token\blx@mkcp@bbl
    \expandafter\blx@mksc@gettwo
  \fi
  \ifx\@let@token\blx@mkcp@sgl
    \expandafter\blx@mksc@gettwo
  \fi
  \ifx\@let@token\blx@mkcp@dbl
    \expandafter\blx@mksc@getthree
  \fi
  \ifx\@let@token$%
    \expandafter\blx@mksc@getmath
  \fi
  \if\noexpand\@let@token\relax
    \expandafter\blx@mksc@cs
  \fi
  \blx@mksc@other}

\def\blx@mksc@getmath#1\blx@mksc@other$#2${\blx@mksc@other{{$#2$}}}
\makeatother
Related Question