I'm trying to display a sequence of equations, plainly centred, so without any alignment you get from the align environment. I thought gather
would do the job, but when I try to use mathcal
, I get the error:
! LaTeX Error: \mathcal allowed only in math mode.
It works fine using align. What am I doing wrong?
Minimal code to reproduce:
\documentclass[12pt]{article}
\usepackage{a4}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{align*}
p(f) &= \mathcal{N}\left(f; 0, K\right)
\end{align*}
\begin{gather}
p(f) &= \mathcal{N}\left(f; 0, K\right)
\end{gather}
\end{document}
Best Answer
For several reasons some error catching in AMS environments is awkward; this is a case. The error is not really in
\mathcal
; indeed, if you remove it, the first error message isIf you also remove
\left
and\right
(that shouldn't be there to begin with), the error becomesHmm, there's something wrong with
&
. And this is the real problem: thegather
environment has no alignment point, so&
must not be used in it.Here's an example:
Note that I removed
\left
and\right
that here only do damages. I also removed the call to thea4
package that's obsolete and deprecated.Don't use
align
orgather
as substitutes forequation
(orequation*
) when you have just one formula: they're for multiline displays.