我需要将此方程调整为:
我使用方程式、矩阵和表格环境重新创建了它。
\begin{equation} \hat{J}_x \leftrightarrow \frac{\hbar}{2}
\begin{pmatrix}
\begin{tabular}{ c | c | c | c | c }
0 & 0 & 0 & 0 & \\ \hline
\multirow{2}{*}{0} & 0\ 1 & \multirow{2}{*}{0} & \multirow{2}{*}{0} \\ & 1\ 0 & & \\ \hline
\multirow{3}{*}{0} & \multirow{3}{*}{0} & 0\ \ $\sqrt{2}$\ \ 0 & \multirow{3}{*}{0} \\ & & $\sqrt{2}$\ \ 0\ $\sqrt{2}$ & \\ & & 0\ \ $\sqrt{2}$\ \ 0 & \\ \hline
\multirow{4}{*}{0} & \multirow{4}{*}{0} & \multirow{4}{*}{0} & 0\ $\sqrt{3}$\ 0\ 0 & \\
& & & $\sqrt{3}$\ 0\ 2\ 0 & \\
& & & 0\ 2\ 0\ $\sqrt{3}$ & \\
& & & 0\ 0\ $\sqrt{3}$\ 0& \\ \hline
& & & & $\ddots$ \\
\end{tabular}
\end{pmatrix}
\end{equation}
我得到这个:
但我需要将等式的第一部分对齐到左上角。此外,表格中的对齐方式有点不对。有什么想法吗?
答案1
您可以用它delarray
来对矩阵进行顶部对齐以及gathered
对方程编号进行居中对齐。
\documentclass{article}
\usepackage{amsmath}
\usepackage{delarray}
\begin{document}
\begin{equation}
\begin{gathered}
\hat{J}_x \leftrightarrow \frac{\hbar}{2}
\begin{array}[t]({ c | c | c | c | c })
0 & 0 & 0 & 0 & \vphantom{\Big|} \\
\hline
0 & \begin{matrix} 1 & 0 \\ 0 & 1\end{matrix} & 0 & & \\
\hline
0 & 0 & \begin{matrix}
0 & \sqrt{2} & 0 \\
\sqrt{2} & 0 & \sqrt{2} \\
0 & \sqrt{2} & 0
\end{matrix} & 0 & \\
\hline
0 & 0 & 0 & \begin{matrix}
0 & \sqrt{3} & 0 & 0 \\
\sqrt{3} & 0 & 2 & 0 \\
0 & 2 & 0 & \sqrt{3} \\
0 & 0 & \sqrt{3} & 0
\end{matrix} & \\
\hline
& & & & \ddots
\end{array}
\end{gathered}
\end{equation}
\end{document}
嵌套矩阵比滥用容易得多\multirow
。
消除gathered
收益
另一方面,我认为这并不是很清楚。
如果您改变主意:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\hat{J}_x \leftrightarrow \frac{\hbar}{2}
\left(\begin{array}{ @{} c | c | c | c | c @{} }
0 & 0 & 0 & 0 & \vphantom{\Big|} \\
\hline
0 & \begin{matrix} 1 & 0 \\ 0 & 1\end{matrix} & 0 & & \\
\hline
0 & 0 & \begin{matrix}
0 & \sqrt{2} & 0 \\
\sqrt{2} & 0 & \sqrt{2} \\
0 & \sqrt{2} & 0
\end{matrix} & 0 & \\
\hline
0 & 0 & 0 & \begin{matrix}
0 & \sqrt{3} & 0 & 0 \\
\sqrt{3} & 0 & 2 & 0 \\
0 & 2 & 0 & \sqrt{3} \\
0 & 0 & \sqrt{3} & 0
\end{matrix} & \\
\hline
& & & & \ddots
\end{array}\right)
\end{equation}
\end{document}
您可以通过设置来获得更开放的外观\extrarowheight
。我只会显示它添加到最后的代码,该方法适用于其他两个示例。
\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{equation}
\setlength{\extrarowheight}{2pt}
\hat{J}_x \leftrightarrow \frac{\hbar}{2}
\left(\begin{array}{ @{} c | c | c | c | c @{} }
0 & 0 & 0 & 0 & \vphantom{\Big|} \\
\hline
0 & \begin{matrix} 1 & 0 \\ 0 & 1\end{matrix} & 0 & & \\
\hline
0 & 0 & \begin{matrix}
0 & \sqrt{2} & 0 \\
\sqrt{2} & 0 & \sqrt{2} \\
0 & \sqrt{2} & 0
\end{matrix} & 0 & \\
\hline
0 & 0 & 0 & \begin{matrix}
0 & \sqrt{3} & 0 & 0 \\
\sqrt{3} & 0 & 2 & 0 \\
0 & 2 & 0 & \sqrt{3} \\
0 & 0 & \sqrt{3} & 0
\end{matrix} & \\
\hline
& & & & \ddots
\end{array}\right)
\end{equation}
\end{document}
答案2
您可以使用\raisebox{-\height}
降低框来将其移动到基线以下并\raisebox{\dimexpr-\height+\baselineskip\relax}
使其处于正确的高度:
\documentclass[]{article}
\usepackage[]{amsmath}
\usepackage{multirow}
\begin{document}
\begin{equation} \hat{J}_x \leftrightarrow \frac{\hbar}{2}
\raisebox{\dimexpr-\height+\baselineskip\relax}
{%
$\begin{pmatrix}
\begin{array}{ c | c | c | c | c }
0 & 0 & 0 & 0 & \\ \hline
\multirow{2}{*}{0} & 0\ 1 & \multirow{2}{*}{0} & \multirow{2}{*}{0} \\ & 1\ 0 & & \\ \hline
\multirow{3}{*}{0} & \multirow{3}{*}{0} & 0\ \ \sqrt{2}\ \ 0 & \multirow{3}{*}{0} \\ & & \sqrt{2}\ \ 0\ \sqrt{2} & \\ & & 0\ \ \sqrt{2}\ \ 0 & \\ \hline
\multirow{4}{*}{0} & \multirow{4}{*}{0} & \multirow{4}{*}{0} & 0\ \sqrt{3}\ 0\ 0 & \\
& & & \sqrt{3}\ 0\ 2\ 0 & \\
& & & 0\ 2\ 0\ \sqrt{3} & \\
& & & 0\ 0\ \sqrt{3}\ 0& \\ \hline
& & & & \ddots \\
\end{array}
\end{pmatrix}$%
}
\end{equation}
\end{document}
答案3
如果您希望 eq 号与顶部对齐,则只需将其放在pmatrix
中即可\belowbaseline[-\ht\strutbox]{...}
。
\documentclass{article}
\usepackage{amsmath,multirow,stackengine}
\begin{document}
\begin{equation} \hat{J}_x \leftrightarrow \frac{\hbar}{2}
\belowbaseline[-\ht\strutbox]{$\begin{pmatrix}
\begin{tabular}{ c | c | c | c | c }
0 & 0 & 0 & 0 & \\ \hline
\multirow{2}{*}{0} & 0\ 1 & \multirow{2}{*}{0} & \multirow{2}{*}{0} \\ & 1\ 0 & & \\ \hline
\multirow{3}{*}{0} & \multirow{3}{*}{0} & 0\ \ $\sqrt{2}$\ \ 0 & \multirow{3}{*}{0} \\ & & $\sqrt{2}$\ \ 0\ $\sqrt{2}$ & \\ & & 0\ \ $\sqrt{2}$\ \ 0 & \\ \hline
\multirow{4}{*}{0} & \multirow{4}{*}{0} & \multirow{4}{*}{0} & 0\ $\sqrt{3}$\ 0\ 0 & \\
& & & $\sqrt{3}$\ 0\ 2\ 0 & \\
& & & 0\ 2\ 0\ $\sqrt{3}$ & \\
& & & 0\ 0\ $\sqrt{3}$\ 0& \\ \hline
& & & & $\ddots$ \\
\end{tabular}
\end{pmatrix}$}
\end{equation}
\end{document}
如果你想让数字居中,那么只需将整个数字包裹在\vcenter{\hbox{$\displaystyle...$}}
\documentclass{article}
\usepackage{amsmath,multirow,stackengine}
\begin{document}
\begin{equation} \vcenter{\hbox{$\displaystyle\hat{J}_x \leftrightarrow \frac{\hbar}{2}
\belowbaseline[-\ht\strutbox]{$\begin{pmatrix}
\begin{tabular}{ c | c | c | c | c }
0 & 0 & 0 & 0 & \\ \hline
\multirow{2}{*}{0} & 0\ 1 & \multirow{2}{*}{0} & \multirow{2}{*}{0} \\ & 1\ 0 & & \\ \hline
\multirow{3}{*}{0} & \multirow{3}{*}{0} & 0\ \ $\sqrt{2}$\ \ 0 & \multirow{3}{*}{0} \\ & & $\sqrt{2}$\ \ 0\ $\sqrt{2}$ & \\ & & 0\ \ $\sqrt{2}$\ \ 0 & \\ \hline
\multirow{4}{*}{0} & \multirow{4}{*}{0} & \multirow{4}{*}{0} & 0\ $\sqrt{3}$\ 0\ 0 & \\
& & & $\sqrt{3}$\ 0\ 2\ 0 & \\
& & & 0\ 2\ 0\ $\sqrt{3}$ & \\
& & & 0\ 0\ $\sqrt{3}$\ 0& \\ \hline
& & & & $\ddots$ \\
\end{tabular}
\end{pmatrix}$}$}}
\end{equation}
\end{document}