使用align環境輸入多行公式的技巧

LaTeX技巧:使用align環境輸入多行公式的技巧

 

align是輸入多行公式中最好用的環境,僅僅是個人淺見,因爲他的對齊非常靈活,如果大家需要非常靈巧的對齊方式的多行公式,建議使用align環境,對應的也還有align*和aligned等等類似的環境,這裏不再詳述。下文提供代碼,盡展其風姿綽約。
演示效果圖:







演示代碼:
\documentclass{article}
\pagestyle{empty}
\setcounter{page}{6}
\setlength\textwidth{266.0pt}
\usepackage{CJK}
\usepackage{amsmath}

\begin{CJK}{GBK}{song}
\begin{document}

\begin{align}
  (a + b)^3  &= (a + b) (a +b)^2        \\
             &=(a + b)(a^2 + 2ab + b^2) \\
             &=a^3 + 3a^2b + 3ab^2 + b^3
\end{align}
\begin{align}
  x^2  + y^2 & =1                       \\
  x          &= \sqrt{1-y^2}
\end{align}
This example has two column-pairs.
\begin{align}    \text{Compare }
  x^2 + y^2 &=1               &
  x^3 + y^3 &=1               \\
  x         &=\sqrt   {1-y^2} &
  x         &=\sqrt[3]{1-y^3}
\end{align}
This example has three column-pairs.
\begin{align}
    x    &=y      & X  &= Y  &
      a  &=b+c               \\
    x'   &= y'     &X' &= Y' &
      a' &=b                 \\
  x + x' &= y +y'            &
  X + X' &= Y + Y' & a'b &= c'b
\end{align}

This example has two column-pairs.
\begin{flalign}  \text{Compare }
  x^2 + y^2 &=1               &
  x^3 + y^3 &=1               \\
  x         &=\sqrt   {1-y^2} &
  x         &=\sqrt[3]{1-y^3}
\end{flalign}
This example has three column-pairs.
\begin{flalign}
    x    &=y      & X  &= Y  &
      a  &=b+c               \\
    x'   &= y'     &X' &= Y' &
      a' &=b                 \\
  x + x' &= y +y'            &
  X + X' &= Y + Y' & a'b &= c'b
\end{flalign}

This example has two column-pairs.
\renewcommand\minalignsep{0pt}
\begin{align}    \text{Compare }
  x^2 + y^2 &=1               &
  x^3 + y^3 &=1              \\
  x         &=\sqrt   {1-y^2} &
  x         &=\sqrt[3]{1-y^3}
\end{align}
This example has three column-pairs.
\renewcommand\minalignsep{15pt}
\begin{flalign}
    x    &=y      & X  &= Y  &
      a  &=b+c              \\
    x'   &= y'     &X' &= Y' &
      a' &=b                \\
  x + x' &= y +y'            &
  X + X' &= Y + Y' & a'b &= c'b
\end{flalign}

\renewcommand\minalignsep{2em}
\begin{align}
  x      &=y      && \text{by hypothesis} \\
      x' &= y'     &&\text{by definition} \\
  x + x' &= y + y' && \text{by Axiom 1}
\end{align}

\begin{equation}
\begin{aligned}
  x^2 + y^2  &=1               \\
  x          &=\sqrt{1-y^2}    \\
 \text{and also }y &= \sqrt{1-x^2}
\end{aligned}               \qquad
\begin{gathered}
 (a + b)^2 = a^2 + 2ab + b^2    \\
 (a + b) \cdot (a - b) = a^2 - b^2
\end{gathered}      \end{equation}

\begin{equation}
\begin{aligned}[b]
  x^2 + y^2  &=1               \\
  x          &=\sqrt{1-y^2}    \\
 \text{and also }y &= \sqrt{1-x^2}
\end{aligned}               \qquad
\begin{gathered}[t]
 (a + b)^2 = a^2 + 2ab + b^2    \\
 (a + b) \cdot (a - b) = a^2 - b^2
\end{gathered}
\end{equation}
\newenvironment{rcase}
    {\left.\begin{aligned}}
    {\end{aligned}\right\rbrace}

\begin{equation*}
  \begin{rcase}
    B' &= -\partial\timesE          \\
    E' &=  \partial\times B - 4\pi j \,
  \end{rcase}
  \quad \text {Maxwell's equations}
\end{equation*}

\begin{equation} \begin{aligned}
  V_j &=v_j                      &
  X_i &= x_i - q_ix_j            &
      &= u_j + \sum_{i\ne j} q_i \\
  V_i &= v_i - q_iv_j            &
  X_j &=x_j                      &
  U_i &= u_i
\end{aligned} \end{equation}

\begin{align}
  A_1 &= N_0 (\lambda ; \Omega')
         -  \phi (\lambda ; \Omega')   \\
  A_2 &= \phi (\lambda ; \Omega')
            \phi(\lambda ; \Omega)     \\
\intertext{and finally}
  A_3 &= \mathcal{N} (\lambda ; \omega)
\end{align}
\end{CJK}
\end{document}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章