3

How can I change the align environment (or create a new environment based on align) so that the alignment in the columns of the equation is not rlrlrl… but rrcll while at the same time keeping the position of the equation number at the end of the line?

I came up with the code below which does the alignment-part the way I want it. But the equation number moves a variable space towards the equation. The space depends on the length of the equation.

The idea of how to define the new environment I got from the second answer to this question.

\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} 

3 Answers 3

1

For such complex alignments you can use IEEEeqnarray. You find a guide at 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} 

enter image description here

1

Maybe you should try the package witharrows:

\documentclass{article}
\usepackage{witharrows}
\begin{document}
\begin{DispWithArrows}[format=rrcll]
L_1     \quad & a+b  &{} = {}& c + d & \quad L_1     \\
L_1+L_2 \quad &  x   &{} = {}& y     & \quad L_1+L_2 
\end{DispWithArrows}
\end{document}

Result of the above code

1

Why reinvent the whell when it's so simple to use the alignat environment?

\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} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .