我想创建一个维度矩阵(即与白金汉π定理相关的矩阵)。以下是一个例子:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[latin1]{inputenc}
\begin{document}
\[\begin{array}{l}
\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,{\pi _1}\,\,\,\,\,\,{\pi _2}\,\,\,\,\,\,\,{\pi _3}\\
\begin{array}{*{20}{c}}
u\\
\rho \\
P\\
E\\
L\\
g
\end{array}\left[ {\begin{array}{*{20}{c}}
{{e_1}}\\
{{e_2}}\\
{{e_3}}\\
{{e_4}}\\
{{e_5}}\\
{{e_6}}
\end{array}} \right] = \left[ {\begin{array}{*{20}{c}}
1&0&0&0&0&0\\
0&1&0&0&0&0\\
0&0&1&0&0&0\\
0&{ - 1}&{ - 1}&0&1&0\\
{ - 1}&1&{ - 2}&1&2&{1/2}\\
0&1&0&0&{ - 1}&{ - 1/2}
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
{{e_1}}\\
{{e_2}}\\
{{e_3}}\\
0\\
0\\
0
\end{array}} \right]
\end{array}\]
\end{document}
产生
我确信有更好的方法将 \pi_1、\pi_2 和 \pi_3 分别插入到 6X6 矩阵的第一、第二和第三列上方,但我不知道该怎么做。在此先感谢您的帮助。
答案1
有了nicematrix
它,一切变得简单又方便。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[\begin{bNiceArray}{C}[first-col]
u & e_1\\
\rho & e_2\\
P& e_3\\
E& e_4\\
L& e_5\\
g& e_6\\
\end{bNiceArray}=
\begin{bNiceArray}{CCCCCC}[first-row]
\pi_1 & \pi_2 & \pi_3 & & & \\
1&0&0&0&0&0\\
0&1&0&0&0&0\\
0&0&1&0&0&0\\
0& - 1& - 1&0&1&0\\
- 1&1& - 2&1&2&1/2\\
0&1&0&0& - 1& - 1/2
\end{bNiceArray}
\begin{bNiceArray}{C}
e_1\\
e_2\\
e_3\\
0\\
0\\
0
\end{bNiceArray}
\]
\end{document}
或者尝试让芭芭拉·比顿更快乐一点。(可以使用,\multicolumn{1}{C}{...}
但\pi_i
恕我直言,看起来并不好。)
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[\begin{bNiceArray}{C}[first-col]
u & e_1\\
\rho & e_2\\
P& e_3\\
E& e_4\\
L& e_5\\
g& e_6\\
\end{bNiceArray}=
\begin{bNiceArray}{RRRRRR}[first-row]
\pi_1 & \pi_2 &\pi_3 & & & \\
1&0&0&0&0&0\\
0&1&0&0&0&0\\
0&0&1&0&0&0\\
0& - 1& - 1&0&1&0\\
- 1&1& - 2&1&2&\tfrac{1}{2}\\
0&1&0&0& - 1& - \tfrac{1}{2}
\end{bNiceArray}
\begin{bNiceArray}{C}
e_1\\
e_2\\
e_3\\
0\\
0\\
0
\end{bNiceArray}
\]
\end{document}
答案2
解决方案如下blkarray
:
\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage{blkarray}
\usepackage{bigstrut}
\begin{document}
\[%
\makeatletter \BA@colsep=10pt \makeatother
\begin{blockarray}{cc}
\\
\begin{block}{c@{\quad}[c]}
u & e_1\bigstrut[t] \\
\rho & e_2 \\
P & e_3 \\
E & e_4 \\
L & e_5 \\
g & e_6\bigstrut[b] \\
\end{block}
\end{blockarray}
=
\begin{blockarray}{*{6}{c} c}
\pi_1 & \pi_2 & \pi_3 & \pi_4 & \pi_5 & \pi_6 \\
\begin{block}{[*{6}{r}]!{\!}[c]}
1&0&0&0&0&0 \bigstrut[t] & e_1 \\
0 & 1 & 0 & 0 & 0 & 0 & e_2 \\
0 & 0 & 1 & 0 & 0 & 0 & e_3 \\
0 & -1 & -1 & 0 & 1 & 0 & 0 \\
-1 & 1 & -2 & 1 & 2 & \mathllap{1}/2 & 0 \\
0 & 1 & 0 & 0 & -1 & \mathllap{-1}/2 \bigstrut[b] & 0 \\
\end{block}
\end{blockarray}
\]%
\end{document}