数组中出现“!缺少数字,视为零。”错误

数组中出现“!缺少数字,视为零。”错误
\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}

给出的错误信息是:

! 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.)  

当我删除下面的粗体部分(第 269 行)时,它可以正常工作:

\[ \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] \\  

当我在不同位置运行相关部分时,它没有出现任何错误:

\[ % 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} \]

我的代码有什么问题?

答案1

错误之处相当微妙:\\查找[包含间距选项的以下内容。因此,\\ \relax在最后一行之前可以解决问题。

但排版方程式的更好方法是使用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}

在此处输入图片描述

答案2

在数组中,LaTeX 会在 之后查找可选参数\\,因此如果接下来是方括号,则会出错。尝试\null 在数组最后一行的开头插入。

相关内容