我试图在 alignat 环境中实现与 array 环境中相同的对齐。我想要这个是因为我想单独标记每个方程式。以下是我目前所拥有的:
\documentclass{article}
\usepackage{amsmath}
\usepackage{esvect}
\begin{document}
\begin{equation}
\begin{array}{c@{\ =\ }c@{\ +\ }c@{\ +\ }c}
\vv{P_{M\!D}} & R_{z}\vv{P_{34}} & R_{xyz}\vv{P_{23}} & \vv{P_{2}}, \\
\vv{P_{M\!I}} & R_{z}\vv{P_{67}} & R_{xyz}\vv{P_{56}} & \vv{P_{5}}, \\
\vv{P_{T\!D}} & R_{y}\vv{P_{910}} & R_{xyz}\vv{P_{89}} & \vv{P_{8}}, \\
\vv{P_{T\!I}} & R_{y}\vv{P_{1213}} & R_{xyz}\vv{P_{1112}} & \vv{P_{11}}.
\end{array}
\end{equation}
\begin{alignat}{6}
\vv{P_{M\!D}} && = & R_{z}\vv{P_{34}} && + & R_{xyz}\vv{P_{23}} && + & \vv{P_{2}}, \label{eq:4}\\
\vv{P_{M\!I}} && = & R_{z}\vv{P_{67}} && + & R_{xyz}\vv{P_{56}} && + & \vv{P_{5}}, \label{eq:5}\\
\vv{P_{T\!D}} && = & R_{y}\vv{P_{910}} && + & R_{xyz}\vv{P_{89}} && + & \vv{P_{8}}, \label{eq:6}\\
\vv{P_{T\!I}} && = & R_{y}\vv{P_{1213}} && + & R_{xyz}\vv{P_{1112}} && + & \vv{P_{11}}. \label{eq:7}
\end{alignat}
\end{document}
第一个方程显示了所需的对齐方式(在每列中居中),但没有标记每条线。第二个方程标记了每条线,但对齐方式不符合要求。
我怎样才能实现第一个方程的对齐,但又像第二个方程一样为每个方程设置单独的标签?
答案1
您可以使用IEEEeqnarray
from IEEEtrantools
。列类型c
代表“以普通对象为中心”,C
代表“以二元运算或关系为中心”。
\documentclass{article}
\usepackage{amsmath}
\usepackage{IEEEtrantools}
\usepackage{esvect}
\begin{document}
\begin{equation}
\begin{array}{c@{\ =\ }c@{\ +\ }c@{\ +\ }c}
\vv{P_{M\!D}} & R_{z}\vv{P_{34}} & R_{xyz}\vv{P_{23}} & \vv{P_{2}}, \\
\vv{P_{M\!I}} & R_{z}\vv{P_{67}} & R_{xyz}\vv{P_{56}} & \vv{P_{5}}, \\
\vv{P_{T\!D}} & R_{y}\vv{P_{910}} & R_{xyz}\vv{P_{89}} & \vv{P_{8}}, \\
\vv{P_{T\!I}} & R_{y}\vv{P_{1213}} & R_{xyz}\vv{P_{1112}} & \vv{P_{11}}.
\end{array}
\end{equation}
\begin{IEEEeqnarray}{c C c C c C c}
\vv{P_{M\!D}} & = & R_{z}\vv{P_{34}} & + & R_{xyz}\vv{P_{23}} & + & \vv{P_{2}}, \label{eq:4}\\
\vv{P_{M\!I}} & = & R_{z}\vv{P_{67}} & + & R_{xyz}\vv{P_{56}} & + & \vv{P_{5}}, \label{eq:5}\\
\vv{P_{T\!D}} & = & R_{y}\vv{P_{910}} & + & R_{xyz}\vv{P_{89}} & + & \vv{P_{8}}, \label{eq:6}\\
\vv{P_{T\!I}} & = & R_{y}\vv{P_{1213}} & + & R_{xyz}\vv{P_{1112}} & + & \vv{P_{11}}. \label{eq:7}
\end{IEEEeqnarray}
\end{document}
答案2
就我个人而言,我看不出有什么令人信服的理由将隐式列的内容居中而不是左对齐。顺便说一句,使用正确的语法,环境alignat
应该将3
而不是6
作为其参数。
从可读性的角度来看,让箭头仅跨越字母“P”具有巨大的优势——参见下面的公式 6 至 9。
\documentclass{article}
\usepackage{amsmath,esvect}
\newcommand\vn[1]{\mathit{#1}} % 'vn' is short for 'variable name'
\begin{document}
\begin{equation}
\begin{array}{r @{{}={}} l @{{}+{}} l @{{}+{}} l}
\vv{P_{\vn{MD}}} & R_{z}\vv{P_{34}} & R_{\vn{xyz}}\vv{P_{23}} & \vv{P_{2}}, \\
\vv{P_{\vn{MI}}} & R_{z}\vv{P_{67}} & R_{\vn{xyz}}\vv{P_{56}} & \vv{P_{5}}, \\
\vv{P_{\vn{TD}}} & R_{y}\vv{P_{910}} & R_{\vn{xyz}}\vv{P_{89}} & \vv{P_{8}}, \\
\vv{P_{\vn{TI}}} & R_{y}\vv{P_{1213}} & R_{\vn{xyz}}\vv{P_{1112}} & \vv{P_{11}}.
\end{array}
\end{equation}
\begin{alignat}{3}
\vv{P_{\vn{MD}}} &= R_{z}\vv{P_{34}} && + R_{\vn{xyz}}\vv{P_{23}} && + \vv{P_{2}}, \label{eq:2}\\
\vv{P_{\vn{MI}}} &= R_{z}\vv{P_{67}} && + R_{\vn{xyz}}\vv{P_{56}} && + \vv{P_{5}}, \label{eq:3}\\
\vv{P_{\vn{TD}}} &= R_{y}\vv{P_{910}} && + R_{\vn{xyz}}\vv{P_{89}} && + \vv{P_{8}}, \label{eq:4}\\
\vv{P_{\vn{TI}}} &= R_{y}\vv{P_{1213}} && + R_{\vn{xyz}}\vv{P_{1112}} && + \vv{P_{11}}.\label{eq:5}
\end{alignat}
\begin{alignat}{3}
\vv{P}_{\!\vn{MD}} &= R_{z}\vv{P}_{\!34} && + R_{\vn{xyz}}\vv{P}_{\!23} && + \vv{P}_{\!2}, \label{eq:6}\\
\vv{P}_{\!\vn{MI}} &= R_{z}\vv{P}_{\!67} && + R_{\vn{xyz}}\vv{P}_{\!56} && + \vv{P}_{\!5}, \label{eq:7}\\
\vv{P}_{\!\vn{TD}} &= R_{y}\vv{P}_{\!910} && + R_{\vn{xyz}}\vv{P}_{\!89} && + \vv{P}_{\!8}, \label{eq:8}\\
\vv{P}_{\!\vn{TI}} &= R_{y}\vv{P}_{\!1213} && + R_{\vn{xyz}}\vv{P}_{\!1112} && + \vv{P}_{\!11}.\label{eq:9}
\end{alignat}
\end{document}