[Latex] Math Equations

史意致
2023-12-01

1. amsmath

Since I am from school of mathematics, the most useful package for me is the amsmath, which helps me write beautiful math formulas.

1.1 Inline equations

We can use $...$ to write inline equations. For example

This is first inline equation $\alpha_1 +\beta_1 = \gamma_1$, \(\alpha_2+\beta_2=\gamma_2\)

Result

1.2 Displayed equations

  • Recommended environments
    • \[...\] un-numbered
    • \begin{equation*}...\end{equation*} un-numbered
    • \begin{equation}...\end{equation} numbered automatically
  • Seldom use
    • \begin{math}...\end{math}
    • \begin{displaymath}...\end{displaymath}
  • Not recommended
    • $$...$$
% alternative 1
\[\sqrt{\mu+\delta}=\kappa\]

% alternative 2
\begin{equation*}
  \sqrt{\mu+\delta}=\kappa
\end{equation*}

% alternative 3
\begin{equation}
  \sqrt{\mu+\delta}=\kappa
\end{equation}

1.3 multi-line equations

Alternatives

  • Recommended
    • \begin{split}...\end{split} which is a subordinate environment that can be used as the contents of equation environment or the contents of one line in a multiple equation structure such as align or gather.
    • \begin{multline}...\end{multline} not-aligned
    • \begin{gather}...\end{gather} not-aligned
    • \begin{align}...\end{align} aligned
  • Not recommended
    • \begin{eqnarray*}...\end{eqnarray*} un-numbered
    • \begin{eqnarray}...\end{eqnarray} numbered
    • because they produce inconsistent spacing of the equal signs and make no attempt to prevent overprinting of the equation body and equation number.
% split
\begin{equation}
  \begin{split}
    \xi+\zeta&=\theta\\
    \mu+\phi&=\tau
  \end{split}
\end{equation}

% gather
\begin{gather}
  a+b+c+d+e+f+g+h+j+\\
  k+l+m+n
\end{gather}

% multline
\begin{multline}
  a+b+c+d+e+f+g+h+j+\\
  k+l+m+n
\end{multline}

% align
\begin{align}
  a+b&=c\\
  d+e&=f
\end{align}

1.4 Details

  • -and ^ are not for lower and upper subsripts
  • \sum for sum
  • \int for integral
  • \sin \cos for sin,cos
  • \sqrt for square root
  • \cdot for one dot in the center of text
  • \cdots for three dots in the center of text
  • \ldots for three dots in the bottom of text
  • \{\} for {}
  • \| for |
  • \text{} for writing text in equation
  • \intertext{} for writing text between multilines
 类似资料: