1

This is a request of clarification for a quirk I've found with the accepted solution of Typesetting chemical element names

If I attempt to use such solution, and I define a couple of new macros as

\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}
\newcommand{\AlO}{\chem{Al_{2}O_{3}}}

using the latter in the bibliography (managed through Biblatex + Biber backend) gives me lots of errors of the kind:

! Missing } inserted.
<inserted text>
}
l.835
?
! Extra }, or forgotten \endgroup.
\MakeLowercase  ... {\lowercase {#1}}\reserved@a }
l.835
?
! LaTeX Error: \mathrm allowed only in math mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...
l.835
?
! Missing $ inserted.
<inserted text>
$
l.835

In the rest of the text things seem working fine. I'm relatively new to Latex, is there something I'm doing wrong?

1
  • Can you please show us a complete example document along with the offending .bib entries that reproduces the issue. See tex.meta.stackexchange.com/q/228/35864 and tex.meta.stackexchange.com/q/4407/35864. I'm guessing it could have something to do with a style that applies sentence case, in which case curly braces around your macros might help, i.e. title = {Foo {\AlO} bar},, but I might be horribly wrong.
    – moewe
    Oct 24, 2018 at 9:29

1 Answer 1

2

An error like this appears when you use \AlO in the title of an entry that your bibliography style converts into sentence case with \MakeSentenceCase*.

@book{hacker,
  author  = {James Hacker},
  title   = {On the Properties of \AlO and More},
  date    = {1980},
}

You need to protect \AlO from the workings of \MakeSentenceCase* and case conversion with double curly braces.

Note that since curly braces are used as argument delimiters for macros and as protection from sentence casing you may have to use more pairs of braces than one would initially think, the minimum number of braces can also depend on the definition of the involved macro.

For protection from case changing for certain words (like proper nouns), see BibTeX loses capitals when creating .bbl file. Also related What is the proper casing to use when storing titles in the bibliography database?, Biblatex changes capitalisation of titles and Biblatex-apa error message when compiling.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

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

\newcommand{\chem}[1]{\ensuremath{\mathrm{#1}}}
\newcommand{\AlO}{\chem{Al_{2}O_{3}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{hacker,
  author  = {James Hacker},
  title   = {On the Properties of {{\AlO}} and More},
  date    = {1980},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{hacker}
\printbibliography
\end{document}

 J. Hacker, On the properties of Al_2O_3 and more (1980).

2
  • That worked perfectly, thanks! I didn't know Biblatex's own formatting would interfere with the newly declared macros.
    – Michele
    Oct 24, 2018 at 13:41
  • @Michele This only becomes relevant when your style applies sentence case with \MakeSentenceCase* (or the unstarred version) and is documented on pp. 235-236 of the biblatex documentation.
    – moewe
    Oct 24, 2018 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .