LaTeX技巧207:使用align环境输入多行公式的技巧

来源:互联网 发布:js得到当前时间 编辑:程序博客网 时间:2024/05/29 16:58

http://blog.sina.com.cn/s/blog_5e16f1770100gror.html

原作的博客里有很多latex相关文章,值得学习。



align是输入多行公式中最好用的环境,仅仅是个人浅见,因为他的对齐非常灵活,如果大家需要非常灵巧的对齐方式的多行公式,建议使用align环境,对应的也还有align*和aligned等等类似的环境,这里不再详述。下文提供代码,尽展其风姿绰约。
演示效果图:

LaTeX技巧207:使用align环境输入多行公式的技巧
LaTeX技巧207:使用align环境输入多行公式的技巧

LaTeX技巧207:使用align环境输入多行公式的技巧 
LaTeX技巧207:使用align环境输入多行公式的技巧

演示代码:
\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\times E          \\
    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_i x_j            &
      &= u_j + \sum_{i\ne j} q_i \\
  V_i &= v_i - q_i v_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}


0 0
原创粉丝点击