Latex: 插入数学公式

  1. align equations to left
    To only align one equation, you can
\begin{flalign}
    &\text{your equation}&
\end{flalign}

To align several equations, you can

\begin{flalign}
    \begin{split}
        your equation (1)\\
        your equation (2)
    \end{split}&
\end{flalign}
  1. 插入矩阵大括号[1]
    插入圆括号
\left (
\begin{array}{l l l}
(\omega^2-\frac{B_0^2 k^2}{4\pi\rho_0}) & 0 & 0\\
0 & (\omega^2-\frac{B_0^2 k^2}{4\pi\rho_0}) & 0 \\
0 & 0 & (\omega^2-\frac{\gamma p_0 k_z^2}{\rho_0^2})\\
\end{array}
\right )

插入单边括号

\begin{equation}
\left \{
\begin{array}{l}
(\frac{\omega}{k_z})^2=\frac{B_0^2}{4\pi\rho_0}=V_A^2\\
(\frac{\omega}{k_z})^2=\frac{\gamma p_0}{\rho_0}=V_s^2\\
\end{array}
\right .
\end{equation}

其中的大括号可以通过\left, \right的命令实现,并且其长度还可以根据矩阵的大小自动调整。注意插入单边括号时,结束处的right . 不可以省略,即便其并没有显示效果。
3. 给数学公式添加强调方框可以使用boxed命令[2]

\begin{equation}
\boxed{
\nabla^2\vec{E}=\mu_0\xi_0\frac{\partial^2\vec{E}}{\partial t^2}
}
\end{equation}
效果如下:

\begin{equation}
\boxed{
\nabla2\vec{E}=\mu_0\xi_0\frac{\partial2\vec{E}}{\partial t^2}
}
\end{equation}
4. 插入源代码
可以使用lstlisting

\usepackage{listings}% insert source codes using list
\begin{lstlisting}
from sys import path
path.append('/home/nan/codes/python/test/mod_package/')
\end{lstlisting}

但是这种方式在插入beamer的frame中时会出现错误,需要替代的方法。解决的方法是在frame的后面添加[fragile]参数,l例如:

\begin{frame}[fragile]{Calculate $\delta B_0$ from CPSD}
The mode strength I calculate is from the cross power spectrum of two near mirnov coils. Thus the strength should be:
\begin{lstlisting}
int main() {
CStash intStash, stringStash;
int i;
char* cp;
ifstream in;
string line;
[...]
\end{lstlisting}
\end{frame}

当然,除了lstlisting可以用,也可以以使用verbatim添加源代码,这时不需要引用额外的库。

参考:
For more latex math symbol can be referred from this site: http://web.ift.uib.no/Teori/KURS/WRK/TeX/symALL.html
[1]https://www.sharelatex.com/learn/Brackets_and_Parentheses
[2]https://math-linux.com/latex-26/faq/latex-faq/article/how-to-display-formulas-inside-a-box-or-frame-in-latex-boxed

posted on 2016-07-17 11:08  DocNan  阅读(1231)  评论(0编辑  收藏  举报

导航