# Errors in matrix equation?

I'm getting errors in a matrix equation. When I compile it looks fine, but I'd like to fix them so I don't have to press return for every error at compile time. The code for the equation is:

\begin{equation*}

\begin{bmatrix}
U(1,t)  & \cdots & U(n,t) \\
\vdots & \ddots & \vdots \\
O_{n1} & \cdots & O_{nn}
\end{bmatrix}
\times
\begin{bmatrix}
W(1,1)  & \cdots & W(1,n) \\
\vdots & \ddots & \vdots \\
W(n,1) & \cdots & W(n,n)
\end{bmatrix}
=
\begin{bmatrix}
D(1,t)  & \cdots & D(n,t) \\
\vdots & \ddots & \vdots \\
I_{n1} & \cdots & I_{nn}
\end{bmatrix}

\end{equation*}


The errors I'm getting are related to missing $'s inserted. - ## 3 Answers If you remove the empty lines after \begin{equation*} and before \end{equation*} the error messages disappear. - I do not get any message with this one: \documentclass{article} \usepackage{amsmath} \begin{document} $\begin{bmatrix} U(1,t) & \cdots & U(n,t) \\ \vdots & \ddots & \vdots \\ O_{n1} & \cdots & O_{nn} \end{bmatrix} \times \begin{bmatrix} W(1,1) & \cdots & W(1,n) \\ \vdots & \ddots & \vdots \\ W(n,1) & \cdots & W(n,n) \end{bmatrix} = \begin{bmatrix} D(1,t) & \cdots & D(n,t) \\ \vdots & \ddots & \vdots \\ I_{n1} & \cdots & I_{nn} \end{bmatrix}$ \end{document}  - You're not getting error messages because you don't have blank lines after $ and before $, right? – Mico Oct 4 '14 at 14:20 sure, amsmath do not like empty lines inside math environments. – Herbert Oct 4 '14 at 14:25 I thought it might be helpful for readers of this answer if it were stated explicitly what was causing the error to disappear. :-) – Mico Oct 4 '14 at 14:27 The point is a line end is turned into a space by TeX, but two line ends are turned into a \par, unless I'm much mistaken. Both answers give a solution removing the two ends of lines. The second one is also reminding me amsmath redefines $ and $ to begin and end equation*. In any case, equation* clearly enters math mode, as can be seen by looking at its definition. So you can try seeing what happens with \par in math mode, and observe that the following: \documentclass[a4paper]{report} \begin{document} $$\par$$ \end{document}  produces: ./muMWE.tex:4: Missing$ inserted.
<inserted text>
$l.4 $$\par$$  which is precisely your error. To know precisely why that happens, you may want to read the TeXBook or TeX by topic. I cannot tell you since I haven't yet read those, but I will read the latter - and have already started. - @Mico The answer is correct; it's TeX that doesn't allow blank lines (or \par, which is the same) in math mode. Quoting the TeXbook (Chapter 26 “Summary of math mode”, page 293): “For example, if a \par command appears [in math mode], or if any other inherently non-mathematical command is given, TeX will try to insert a ‘$’ just before the offending token; this will lead out of math mode.” –  egreg Oct 4 '14 at 16:41
Just a little detail @egreg: AFAIK \par is the same as two end-of-line characters. Under normal circumstances, that means two ASCII return characters (^^M). However, if someone decides to change the \catcode of ^^M and sets it to something else, introducing a new end-of-line character, blank lines should not turn to \par. Is that right? –  MickG Oct 4 '14 at 16:51
@MickG It's a bit more complicated than that, but, basically, two consecutive characters with category code 5 will be converted to \par. Yes, changing the category code of ^^M from 5 to another value or suppressing \endlinechar (with \endlinechar=-1) will not convert an empty line into \par. –  egreg Oct 4 '14 at 16:54
I guess expanding on "a bit more complicated" could be done by reading one of the linked references, right :)? –  MickG Oct 4 '14 at 17:03