5
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}  % change later to \usepackage{geometry}
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm,
headheight=0cm,headsep=0cm,footskip=0cm,nomarginpar}
\pagestyle{empty}
\setlength{\parskip}{0bp}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{babel}
\usepackage{ulem}

\begin{document}

\def\arraystretch{2}
\[ \begin{array}{rcl}
C_\theta H^T [HC_\theta H^T + C_\eta]^{-1} &=& [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1} \\
C_\theta H^T [HC_\theta H^T + C_\eta]^{-1}[HC_\theta H^T + C_\eta] &=& [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1}[HC_\theta H^T + C_\eta] \\
C_\theta H^T &=& [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1}[HC_\theta H^T + C_\eta] \\
[C_\theta^{-1} + H^T C_\eta^{-1} H] C_\theta H^T & = & [C_\theta^{-1} + H^T C_\eta^{-1} H][C_\theta^{-1} + H^T C_\eta^{-1} H]^{-1} H^T C_\eta^{-1} [H C_\theta H^T + C_\eta] \\
\end{array} \]

\end{document}

Given error message is:

! Missing number, treated as zero.  
<to be read again>  
C  
l.269 [C_\theta^{-1} + H^T C_\eta^{-1} H]  
C_\theta H^T & = & [C_\theta^{-1} ...  
A number should have been here; I inserted `0'.  
(If you can't figure out why I needed to see a number,  
look up `weird error' in the index to The TeXbook.)  
! Illegal unit of measure (pt inserted).  
<to be read again>  
C  
l.269 [C_\theta^{-1} + H^T C_\eta^{-1} H]  
C_\theta H^T & = & [C_\theta^{-1} ...  
Dimensions can be in units of em, ex, in, pt, pc,  
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!  
I'll assume that you meant to say pt, for printer's points.  
To recover gracefully from this error, it's best to  
delete the erroneous units; e.g., type `2' to delete  
two letters. (See Chapter 27 of The TeXbook.)  
! Missing = inserted for \ifdim.  
<to be read again>  
C  
l.269 [C_\theta^{-1} + H^T C_\eta^{-1} H]  
C_\theta H^T & = & [C_\theta^{-1} ...  
I was expecting to see `<', `=', or `>'. Didn't.  
! Missing number, treated as zero.  
<to be read again>  
C  
l.269 [C_\theta^{-1} + H^T C_\eta^{-1} H]  
C_\theta H^T & = & [C_\theta^{-1} ...  
A number should have been here; I inserted `0'.  
(If you can't figure out why I needed to see a number,  
look up `weird error' in the index to The TeXbook.)  
! Illegal unit of measure (pt inserted).  
<to be read again>  
C  
l.269 [C_\theta^{-1} + H^T C_\eta^{-1} H]  
C_\theta H^T & = & [C_\theta^{-1} ...  
Dimensions can be in units of em, ex, in, pt, pc,  
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!  
I'll assume that you meant to say pt, for printer's points.  
To recover gracefully from this error, it's best to  
delete the erroneous units; e.g., type `2' to delete  
two letters. (See Chapter 27 of The TeXbook.)  

It works alright when I remove the bold part (at line 269) below:

\[ \begin{array}{rcl}  
C_\theta H^T [HC_\theta H^T + C_\eta]^{-1} &=& [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1} \\  
C_\theta H^T [HC_\theta H^T + C_\eta]^{-1}[HC_\theta H^T + C_\eta] &=& [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1}[HC_\theta H^T + C_\eta] \\  
C_\theta H^T &=& [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1}[HC_\theta H^T + C_\eta] \\  
**[C_\theta^{-1} + H^T C_\eta^{-1} H]** C_\theta H^T & = & [C_\theta^{-1} + H^T C_\eta^{-1} H][C_\theta^{-1} + H^T C_\eta^{-1} H]^{-1} H^T C_\eta^{-1} [H C_\theta H^T + C_\eta] \\  

It doesn't give any error when I run the relevant part in a different location:

\[ % No errors given for this:
 [C_\theta^{-1} + H^T C_\eta^{-1} H] C_\theta H^T = [C_\theta^{-1} + H^T C_\eta^{-1} H][C_\theta^{-1} + H^T C_\eta^{-1} H]^{-1} H^T C_\eta^{-1} [H C_\theta H^T + C_\eta] \]
\end{array} \]

What is wrong with my code?

1
  • You wouldn't have the error if you used the align* environment. – egreg Apr 15 '13 at 14:00
6

The wrong thing is quite subtle: \\ looks for a following [ that contains the spacing option. So \\ \relax before the last line would solve the issue.

But a better way to typeset your equations is with align*:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
C_\theta H^T [HC_\theta H^T + C_\eta]^{-1} &= [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1} \\
C_\theta H^T [HC_\theta H^T + C_\eta]^{-1}[HC_\theta H^T + C_\eta] &=[C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1}[HC_\theta H^T + C_\eta] \\
C_\theta H^T &= [C_\theta^{-1}+H^TC_\eta^{-1}H]^{-1}H^TC_\eta^{-1}[HC_\theta H^T + C_\eta] \\
[C_\theta^{-1} + H^T C_\eta^{-1} H] C_\theta H^T & = [C_\theta^{-1} + H^T C_\eta^{-1} H][C_\theta^{-1} + H^T C_\eta^{-1} H]^{-1} H^T C_\eta^{-1} [H C_\theta H^T + C_\eta] \\
\end{align*}

\end{document}

enter image description here

3

In an array, LaTeX looks for an optional argument after \\, so you get an error if a square bracket comes next. Try inserting \null at the start of the last line of your array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.