我正在尝试在文章中打印以下等式
H = \begin{pmatrix}
1 & x_{11} & \cdots & x_{1p} \\
1 & x_{21} & \cdots & x_{2p} \\
\cdots & \cdots & \cdots & \cdots \\
1 & x_{n1} & \cdots & x_{np} \\
\end{pmatrix}
\begin{pmatrix}
q_{11} & q_{12} & \cdots & q_{1p+1} \\
q_{21} & q_{22} & \cdots & q_{2p+1} \\
\cdots & \cdots & \cdots & \cdots \\
q_{p+11} & q_{p+12} & \cdots & q_{p+1p+1} \\
\end{pmatrix}
\begin{pmatrix}
1 & 1 & \cdots & 1 \\
x_{11} & x_{21} & \cdots & x_{n1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{1p} & x_{2p} & \cdots & x_{np} \\
\end{pmatrix}
=
\begin{pmatrix}
x_{1}^{t}q_{1} & x_{1}^{t}q_{2} & \cdots & x_{1}^{t}q_{p+1} \\
x_{2}^{t}q_{1} & x_{2}^{t}q_{2} & \cdots & x_{2}^{t}q_{p+1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{n}^{t}q_{1} & x_{n}^{t}q_{2} & \cdots & x_{n}^{t}q_{p+1} \\
\end{pmatrix}
\begin{pmatrix}
1 & 1 & \cdots & 1 \\
x_{11} & x_{21} & \cdots & x_{n1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{1p} & x_{2p} & \cdots & x_{np} \\
\end{pmatrix}
我将代码像您所见的那样放置在\equation
和之间$$
,但是方程被矩阵分成一行,如何解决它并将方程正确地放在代码中。
答案1
\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{gathered}
H = \begin{pmatrix}
1 & x_{11} & \cdots & x_{1p} \\
1 & x_{21} & \cdots & x_{2p} \\
\cdots & \cdots & \cdots & \cdots \\
1 & x_{n1} & \cdots & x_{np} \\
\end{pmatrix}
%
\begin{pmatrix}
q_{11} & q_{12} & \cdots & q_{1p+1} \\
q_{21} & q_{22} & \cdots & q_{2p+1} \\
\cdots & \cdots & \cdots & \cdots \\
q_{p+11} & q_{p+12} & \cdots & q_{p+1p+1} \\
\end{pmatrix}
%
\begin{pmatrix}
1 & 1 & \cdots & 1 \\
x_{11} & x_{21} & \cdots & x_{n1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{1p} & x_{2p} & \cdots & x_{np} \\
\end{pmatrix}
%
= \\
%
\begin{pmatrix}
x_{1}^{t}q_{1} & x_{1}^{t}q_{2} & \cdots & x_{1}^{t}q_{p+1} \\
x_{2}^{t}q_{1} & x_{2}^{t}q_{2} & \cdots & x_{2}^{t}q_{p+1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{n}^{t}q_{1} & x_{n}^{t}q_{2} & \cdots & x_{n}^{t}q_{p+1} \\
\end{pmatrix}
%
\begin{pmatrix}
1 & 1 & \cdots & 1 \\
x_{11} & x_{21} & \cdots & x_{n1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{1p} & x_{2p} & \cdots & x_{np} \\
\end{pmatrix}
\end{gathered}
\end{equation*}
\end{document}
答案2
关于您的代码的一些评论:
首先,删除数学环境中的所有空行。
我认为,从印刷术上来说,使用
\cdots
as这矩阵中所有位置均使用印刷省略号。在第 1、2 和 4 行中,应为\dots
(或\ldots
)。在第 3 行中,四条\cdots
指令中有三条实际上应该是\vdots
;但四条指令中的第三条应该是\ddots
。矩阵第 1 行的下标符号
Q
设计得不太好。例如,不要写1p+1
和p+12
,而要写1,p+1
和p+1,2
,等等。您在第二行第一个矩阵中使用的转置符号选择得不好。我建议您在两个向量之间放置转置符号(可以是
^t
、^{\prime}
、^{\top}
或任何您喜欢的符号)。
\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page dimensions appropriately
\usepackage{amsmath} % for 'align*' and 'pmatrix' environments
\begin{document}
\begin{align*}
H
&= \begin{pmatrix}
1 & x_{11} & \dots & x_{1p} \\
1 & x_{21} & \dots & x_{2p} \\
\vdots & \vdots & \ddots & \vdots \\
1 & x_{n1} & \dots & x_{np}
\end{pmatrix}%_{\!\!\!n\times(p+1)}
\begin{pmatrix}
q_{11} & q_{12} & \dots & q_{1,p+1} \\
q_{21} & q_{22} & \dots & q_{2,p+1} \\
\vdots & \vdots & \ddots & \vdots \\
q_{p+1,1} & q_{p+1,2} & \dots & q_{p+1,p+1}
\end{pmatrix}%_{\!\!\!(p+1)\times(p+1)}
\begin{pmatrix}
1 & 1 & \dots & 1 \\
x_{11} & x_{21} & \dots & x_{n1} \\
\vdots & \vdots & \ddots & \vdots \\
x_{1p} & x_{2p} & \dots & x_{np}
\end{pmatrix}%_{\!\!\!(p+1)\times n}
\\
&= \begin{pmatrix}
x_{1}{}'q_{1} & x_{1}{}'q_{2} & \dots & x_{1}{}'q_{p+1} \\
x_{2}{}'q_{1} & x_{2}{}'q_{2} & \dots & x_{2}{}'q_{p+1} \\
\vdots & \vdots & \ddots & \vdots \\
x_{n}{}'q_{1} & x_{n}{}'q_{2} & \dots & x_{n}{}'q_{p+1}
\end{pmatrix}
\begin{pmatrix}
1 & 1 & \dots & 1 \\
x_{11} & x_{21} & \dots & x_{n1} \\
\vdots & \vdots & \ddots & \vdots \\
x_{1p} & x_{2p} & \dots & x_{np}
\end{pmatrix}
\end{align*}
\end{document}