\mathsf
takes an argument, it doesn't make the following expression sans serif. You can switch to math sans serif, then get the underlying \mathgroup
(\fam
) number and then set that for the entire math expression:
\documentclass{article}
\begin{document}
\boldmath
\everymath{\mathsf{\xdef\mysf{\mathgroup\the\mathgroup\relax}}\mysf}
$abc$
\end{document}
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 is
! Missing $ inserted.
If you also remove \left
and \right
(that shouldn't be there to begin with), the error becomes
! Extra alignment tab has been changed to \cr.
Hmm, there's something wrong with &
. And this is the real problem: the gather
environment has no alignment point, so &
must not be used in it.
Here's an example:
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{align*}
p(f) &= \mathcal{N}(f; 0, K) \\
q(f) &= \mathcal{N}(f; K, 0) + 3
\end{align*}
\begin{gather}
p(f) = \mathcal{N}(f; 0, K) \\
q(f) = \mathcal{N}(f; K, 0) + 3
\end{gather}
\end{document}

Note that I removed \left
and \right
that here only do damages. I also removed the call to the a4
package that's obsolete and deprecated.
Don't use align
or gather
as substitutes for equation
(or equation*
) when you have just one formula: they're for multiline displays.
Best Answer
No, I don't, but according to comments by percusse and Manuel you can do that by loading mathtools instead of amsmath and use
\begin{vmatrix*}[r] … \end{vmatrix*}
. I haven't checked though by myself. But I do recomment keep the standard alignement provided by\begin{vmatrix} ... \end{vmatrix}
.UPDATE with align. Thanks to cmhughes's advice I've replaced
eqnarray
withalign
and&=&
with&=
. ADDED. As commented by egregeqnarray
should be avoided (see e.g. here and here) due to spacing discrepancies.The updated code is:
The Output is:
We can use the following code (with eqnarray)
to type