0

TeXtudio gives me the error Misplaced alignment tab character &. in the line where I insert my bibliography. This line is \include{\dir/bibliography} which links to

\manualmark%
\markboth{\spacedlowsmallcaps{\bibname}}{\spacedlowsmallcaps{\bibname}}
\refstepcounter{dummy}
\addtocontents{toc}{\protect\vspace{\beforebibskip}} 
\addcontentsline{toc}{chapter}{\tocEntry{\bibname}}
\label{app:bibliography}

\emergencystretch=1em%
\printbibliography

I think the problem might be caused by & symbols within the references, of which there are very many. I could replace them with \& or "and", but maybe there's an easier solution.

I'm using MiKTeX and Biber.

1
  • 3
    Replacing & with \& in the .bib file is generally the easiest solution (and running Biber again afterwards). With a Replace All function in an editor this can be done very quickly.
    – Marijn
    Commented Apr 17, 2020 at 10:05

2 Answers 2

2

The character & has a special meaning for LaTeX: It marks new table columns or new alignment columns in general (think align).

As such you can't generally use & in its meaning as ampersand character in standard LaTeX and must escape it to \&, see Escape character in LaTeX. There are some exceptions to this rule: In \verb|...| and other verbatim commands as well as \url and some related commands you can often use & without escaping it, but there are some subtle points with those commands (see for example How to use a link as footnote that has special characters inside?).

It's pretty much the same for the bibliography. You should escape & to \& in .bib files except in special verbatim fields like doi, eprint and url.

The best solution™ is to make sure to escape & to \& in the .bib file unless it is in a doi, eprint, url or otherwise verbatim field. E.g. instead of

publisher = {Pub & Co.},

you should write

publisher = {Pub \& Co.},

If for some reason you absolutely cannot bring yourself to fix your .bib file once for good, you can have Biber do that on the fly for you (but this is at most the second best solution™). (biblatex uses an XML format to communicate with Biber, where & is also a special character, so we better escape it as \x{26}.)

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

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

\DeclareSourcemap{
  \maps{
    \map{
      \step[fieldsource=publisher,
        match=\regexp{\x{26}},
        replace=\regexp{\\\x{26}}]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@book{appleby,
  author    = {Humphrey Appleby},
  title     = {On the Importance of the Civil Service},
  date      = {1980},
  publisher = {Pub & Co.},
}
\end{filecontents}
\addbibresource{\jobname.bib}


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

"Pub & Co." displayed as desired

Related Ampersand in Sourcemap for BibTex.

0

You are right. '&' has special meaning to (La)TeX, and the result of compiling a bibliography is ultimately processed by LaTeX.

There are names that include '&', like the journal "'Software -- Practice & Experience" or "John Wiley & Sons". Replacing with "and" would be wrong. Go for "\&", the (La)TeX way to type that character.

You must log in to answer this question.

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