I wrote a matrix equation
\[
\left[ \begin{array}{c}
v^{0}_{n} \\
v^{K-1}_{n}
\end{array} \right] =
-\frac{1}{C_{ref}}
\left[ \begin{array}{ccc} V^{0}_{0,n} & \cdots & V^{0}_{M-1,m} \\
\vdots & \ddots & \vdots \\
V^{K-1}_{0,n} & \cdots & V^{K-1}_{M-1,n}
\end{array} \right]
\left[ \begin{array}{c}
C_{0,n} \\
C_{M-1,n}
\end{array}
\right]
\]
I want to put an equation number at the end of this equation. But only way I know how to do that is to put this whole equation in \begin{equation}
and \end{equation}
which gives an error. The error is
Bad math environment delimiter
When I delete \[
and \]
from the start and end of my equation, I no longer get an error. My question is that why am I getting this error just by moving an equation in \begin
and \end
.
Best Answer
The LaTeX macros
\begin{equation}
and\[
both initiate a display-math group, and the macros\end{equation}
and\]
both terminate a display-math group. (In addition, theequation
environment provides a method for numbering the equations, whereas\[ ... \]
does not.) The LaTeX macros\begin{equation}
and\[
are designed purposefully so as not to let users open a display-math group twice; this is why you're getting the error message "Bad math environment delimiter" when LaTeX encounters\[
after having processed\begin{equation}
.The upshot: Use one or the other method for setting up a display-math group, but don't use both simultaneously.
For a more-detailed discussion of how various LaTeX displaymath environments are set up, see this answer to the question "What are the differences between
$$
,\[
,align
,equation
anddisplaymath
?" Shameless self-citation alert!