1

I discovered a problem when using BibLaTeX' cite-style apa together with mhchem when the bib-file contains chemical formulas with subscripts/superscripts. The MWE is

\documentclass{article}
\usepackage[version=4]{mhchem}
\usepackage[style=apa, backend=biber]{biblatex}
%\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{Bib.bib}

\begin{document}

This is a citation with only simple chemistry: \parencite{Cite1}.

This is a citation with superscript: \parencite{Cite2}.

\printbibliography
\end{document}

Cite1 contains only a simple chemical formula and works perfectly fine:

@Article{Cite1,
  author       = {Author, A.},
  date         = {2020},
  journaltitle = {A Journal},
  title        = {A title with just some \ce{Mg/Ca} chemistry},
  issue        = {2},
  pages        = {1--4},
  volume       = {1},
  timestamp    = {2020-03-27},
}

Cite 2 contains superscript, and leads to 14 errors:

@Article{Cite2,
  author       = {Author, B.},
  date         = {2020},
  journaltitle = {Another Journal},
  title        = {A title with some more complicated \ce{\delta^{18}O} chemistry and a longer title},
  issue        = {1},
  pages        = {2--6},
  volume       = {8},
  timestamp    = {2020-03-27},
}

The problem seems to be, that BibLaTeX switches into Mathmode, although \ce should prevent that:

enter image description here

A simple \protect, as in {\protect\ce{\delta^{18}O}}, solves that problem, but creates another, because now the "O" is made lowercase.

enter image description here

I would need the rather convoluted version {\protect\ce{\delta^{18}\MakeUppercase{O}}} to finally get the correct result:

enter image description here

Since the real bib-file contains many entries, I would understandably not like to manually change them all. Curiously, it works perfectly fine with the authoryear-style, the problem is apparently apa-specific. I would be very thankful for any suggestions how to tackle this issue.

1 Answers1

4

biblatex-apa applies sentence casing with \MakeSentenceCase*. That macro is quite complex and can basically only handle plain text without breaking.

If you have complex macros in your titles you need to hide/protect them with a pair of braces.

The complex rules of brace protection mean that you need two pairs of braces if the content in the braces starts with a macro and you want to retain the cpaitalisation.

\documentclass{article}
\usepackage[version=4]{mhchem}
\usepackage[style=apa, backend=biber]{biblatex}


\begin{filecontents}{\jobname.bib}
@Article{Cite1,
  author       = {Author, A.},
  date         = {2020},
  journaltitle = {A Journal},
  title        = {A Title with Just Some {{\ce{Mg/Ca}}} Chemistry},
  issue        = {2},
  pages        = {1--4},
  volume       = {1},
}
@Article{Cite2,
  author       = {Author, B.},
  date         = {2020},
  journaltitle = {Another Journal},
  title        = {A Title with Some More Complicated {{\ce{\delta^{18}O}}}
                  Chemistry and a Longer Title},
  issue        = {1},
  pages        = {2--6},
  volume       = {8},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
This is a citation with only simple chemistry: \parencite{Cite1}.

This is a citation with superscript: \parencite{Cite2}.

\printbibliography
\end{document}

Author, A. (2020). A title with just some Mg/Ca chemistry. A Journal, 1, 1–4.//Author, B. (2020). A title with some more complicated δ 18 O chemistry and a longer title. Another Journal, 8, 2–6.

moewe
  • 175,683