我有一个方程,其中包含一个大矩阵,我想将其编号为方程。我使用下面显示的代码:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath}
\begin{document}
\setcounter{MaxMatrixCols}{20}
\begin{equation}
Y_{12} =
\begin{bmatrix}
-\frac{1}{x'_{d1}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & -\frac{1}{x'_{d2}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & -\frac{1}{x'_{d3}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & -\frac{1}{x'_{d4}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & -\frac{1}{x'_{d5}} & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d6}} & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d7}} & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d8}} & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d9}} & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d10}} & 0 \\
\end{bmatrix} \\
\end{equation}
\end{document}
此代码适用于较小的矩阵。但是对于较大的矩阵,方程的宽度似乎比更宽\textwidth
,因为方程编号位于矩阵下方的行上。我怎样才能在与方程相同的行上获得方程编号?
答案1
这些零有什么用呢?为什么不直接写成具有以下元素的对角矩阵呢:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath,mathtools}
\DeclareMathOperator\diag{diag}
\begin{document}
\begin{equation}
\begin{split}
Y_{12} = -\diag\Bigl( & \frac{1}{x'_{d1}}, \frac{1}{x'_{d2}},
\frac{1}{x'_{d3}}, \frac{1}{x'_{d4}}, \frac{1}{x'_{d5}},
\frac{1}{x'_{d6}},\frac{1}{x'_{d7}}, \frac{1}{x'_{d8}}, \frac{1}{x'_{d9}},
\frac{1}{x'_{d10}} \Bigr)
\end{split}
\end{equation}
\end{document}
对于其他矩阵构造,可以将它们分解成更小的部分,并写出类似的内容:为了简化符号,我们首先定义......
这只是一个不被传统束缚的问题
答案2
使用命令更改的值\arraycolsep
或减小字体大小(约 80% )。如果不使用边距注释,您还可以加载以获得更合理的边距。\medmath
nccmath
displaystyle
geometry
\documentclass[12pt,a4paper]{report}
\usepackage{mathtools, nccmath}
\usepackage{showframe}
\renewcommand*\ShowFrameLinethickness{.3pt}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\begin{equation}\setlength\arraycolsep{2pt}
Y_{12} =
\begin{bmatrix}
-\frac{1}{x'_{d1}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & -\frac{1}{x'_{d2}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & -\frac{1}{x'_{d3}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & -\frac{1}{x'_{d4}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & -\frac{1}{x'_{d5}} & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d6}} & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d7}} & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d8}} & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d9}} & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d10}} & 0 \\
\end{bmatrix}
\end{equation}
\begin{equation}\setlength\arraycolsep{4pt}
Y_{12} =
\medmath{\begin{bmatrix}
-\frac{1}{x'_{d1}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & -\frac{1}{x'_{d2}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & -\frac{1}{x'_{d3}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & -\frac{1}{x'_{d4}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & -\frac{1}{x'_{d5}} & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d6}} & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d7}} & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d8}} & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d9}} & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1}{x'_{d10}} & 0 \\
\end{bmatrix}}
\end{equation}
\end{document}