10

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?

Adam Liter
  • 12,567
  • What's it putting in the .bbl? Is it a Biber issue or a Biblatex one? – cfr Apr 22 '16 at 03:14
  • @cfr Just posted some updates that hopefully clarify things, though I'm about to head to bed. Good night! :) – Adam Liter Apr 22 '16 at 03:30
  • The issue has to do with the \MakeSentenceCase macro, it can be reproduced with the standard styles and \DeclareFieldFormat{titlecase}{\MakeSentenceCase{#1}}. – moewe Apr 22 '16 at 05:19
  • It works fine if you protect the math with a brace: Title = {Psych-Verbs and {$\theta$}-Theory}, (this is the recommended method to protect unusual input from \MakeSentenceCase, see the docu). – Ulrike Fischer Apr 22 '16 at 08:10
  • Sorry didn't see that you actually had already found the braces. As the documentation says: \MakeSentenceCase "support the traditional BibTeX convention for bib files that anything wrapped in a pair of curly braces is not modified when changing the case." and shows some example how to use it in case you don't want it to kick in. – Ulrike Fischer Apr 22 '16 at 08:22

1 Answers1

10

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
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 3
    Do you think this is robust enough to go into the next biblatex release? – PLK Apr 22 '16 at 08:17
  • 1
    Thanks Joseph! :) It would be nice if this could make it into a biblatex release at some point, as this seems like a case that biblatex should be able to handle. – Adam Liter Apr 22 '16 at 18:31
  • 1
    Was just curious if this ever made it into a biblatex release or if it ever will? I still seem to be having this problem (CC: @PLK). – Adam Liter Nov 29 '17 at 15:55