我怎样才能改变align
环境(或基于创建新的环境align
),以便方程式列中的对齐不是rlrlrl…
但rrcll
同时保持方程式编号在行末的位置?
我想出了下面的代码,它按照我想要的方式执行对齐部分。但是方程编号将变量空间移向方程。该空间取决于方程的长度。
关于如何定义新环境,我从第二个答案中得到了这个问题。
\documentclass{article}
\usepackage{amsmath,environ}
\makeatletter
\NewEnviron{gleichungssystem}
{\def\align@preamble{%
&\hfil
\strut@
\setboxz@h{\@lign$\m@th\displaystyle{####}$}%
\ifmeasuring@\savefieldlength@\fi
\set@field
\tabskip2\tabcolsep
&\hfil
\strut@
\setboxz@h{\@lign$\m@th\displaystyle{####}$}%
\ifmeasuring@\savefieldlength@\fi
\set@field
\tabskip\tabcolsep
&\hfil
\strut@
\setboxz@h{\@lign$\m@th\displaystyle{####}$}%
\ifmeasuring@\savefieldlength@\fi
\set@field
\hfil
\tabskip\tabcolsep
&\setboxz@h{\@lign$\m@th\displaystyle{####}$}%
\ifmeasuring@\savefieldlength@\fi
\set@field
\hfil
\tabskip5\tabcolsep
&\setboxz@h{\@lign$\m@th\displaystyle{####}$}%
\ifmeasuring@\savefieldlength@\fi
\set@field
\hfil
\tabskip\alignsep@
}%
\begin{align}\BODY\end{align}}
\makeatother
\begin{document}
\begin{gleichungssystem}
&0 &= &\dot{x}(0) & \\
\stackrel{xxx}{\Leftrightarrow} &0 & = & c_1 i \omega_0 \cdot e^{i \omega_0 0} - c_2 i \omega_0 \cdot e^{-i \omega_0 0} &\left| e^{0} = 1 \right. \\
\Leftrightarrow &0 &= &i \omega_0 c_1 - i \omega_0 c_2 &\left| \cdot \frac{1}{i\omega_0} \right. \\
\Leftrightarrow &0 &= &c_1 - c_2 &\left| + c_2 \right. \\
\Leftrightarrow &c_2 &= &c_1 & \label{umformung_randbed-frei-unged1_bsp1-2}
\end{gleichungssystem}
\begin{gleichungssystem}
&0 &= &\dot{x}(0) & \\
\stackrel{xxx}{\Leftrightarrow} &0 & = & c_1 i \omega_0 \cdot e^{i \omega_0 0} - c_2 i \omega_0 \cdot e^{-i \omega_0 0} &
\end{gleichungssystem}
\begin{equation}
a + b = c
\end{equation}
\end{document}
答案1
对于这种复杂的对齐,您可以使用IEEEeqnarray
。您可以在以下位置找到指南https://moser-isi.ethz.ch/docs/typeset_equations.pdf
\documentclass{article}
\usepackage{amsmath,IEEEtrantools}
\newenvironment{gleichungssystem}
{\begin{IEEEeqnarray}{c'lCLL}}
{
}
\begin{document}
\begin{IEEEeqnarray}{c'lCLL}
& 0 &=& \dot{x}(0)
\\
\overset{xxx}{\Leftrightarrow}
& 0 &=& c_1 i \omega_0 \cdot e^{i \omega_0 0} -
c_2 i \omega_0 \cdot e^{-i \omega_0 0}
& \left| e^{0} = 1 \right.
\\
\Leftrightarrow
& 0 &=& i \omega_0 c_1 - i \omega_0 c_2
& \left| \cdot \frac{1}{i\omega_0} \right.
\\
\Leftrightarrow
& 0 &= &c_1 - c_2
& \left| + c_2 \right.
\\
\Leftrightarrow &c_2 &= &c_1 & \label{umformung_randbed-frei-unged1_bsp1-2}
\end{IEEEeqnarray}
\begin{IEEEeqnarray}{c'RCL}
& 0 &=& \dot{x}(0)
\\
\overset{xxx}{\Leftrightarrow}
& 0 &=& c_1 i \omega_0 \cdot e^{i \omega_0 0} - c_2 i \omega_0 \cdot e^{-i \omega_0 0}
\\
\IEEEeqnarraymulticol{4}{c}{a + b = c}
\end{IEEEeqnarray}
\end{document}
答案2
答案3
既然使用环境如此简单,为何要重新发明轮子alignat
?
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{3}
& & \quad 0 &= \dot{x}(0) \\
& \overset{xxx}{\Leftrightarrow} &0 & = c_1 i \omega_0 \cdot e^{i \omega_0 0} - c_2 i \omega_0 \cdot e^{-i \omega_0 0} &\quad & \left|\; e^{0} = 1 \right. \\
& \Leftrightarrow &0 &= i \omega_0 c_1 - i \omega_0 c_2 & & \left|{} \cdot \frac{1}{i\omega_0} \right. \\
& \Leftrightarrow &0 &= c_1 - c_2 & & \left|{} + c_2 \right. \\
& \Leftrightarrow &c_2 & = c_1 \label{umformung_randbed-frei-unged1_bsp1-2}
\end{alignat}
\begin{alignat}{2}
& &\quad 0 &= \dot{x}(0) \\
& \stackrel{xxx}{\Leftrightarrow} &0 & = c_1 i \omega_0 \cdot e^{i \omega_0 0} - c_2 i \omega_0 \cdot e^{-i \omega_0 0}
\end{alignat}
\begin{equation}
a + b = c
\end{equation}
\end{document}