本次推文主要给大家分享的是:如何在Beamer中添加数学公式?
Latex以公式排版为优势,在数学、物理、化学等领域使用非常频繁,木木就一些在Beamer中常用的公式设置记录在此,当作是小工具书,以后用时再回过头来Copy。
关于Latex公式的生成,可以选择一些主流的公式编辑器进行快速生成,Mathtype、Axmath这两个编辑器我重点推荐,我平时喜欢用Axmath(正版30几块,即可终身使用),界面很舒服,敲公式也很方便。
效果
代码片
\begin{frame}{单行公式}
这是行内公式:$a+b=c$
\qquad
\begin{onlinebox}{3cm}
$\displaystyle \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}$
\end{onlinebox}
\bigskip
\begin{displaybox}{3cm}
\centerline{$x = t+\cos t +1$ }
\end{displaybox}
行间公式带编号:
\begin{equation}
a+b=c
\end{equation}
\bigskip
行间公式不带编号:
\begin{equation*}
a+b=c
\end{equation*}
\end{frame}
代码解读
行内公式可使用 包围即可;
行间公式需\begin{equation}... \end{equation}
环境,默认情况下是编号的,若不想带编号,可以使用\begin{equation*}... \end{equation*}
环境。
效果
代码片
\begin{frame}{多行公式居中}
带标号的公式,
\begin{gather}
a+b=c\notag\\
d-d=u
\end{gather}
\bigskip
不带标号的公式
\begin{gather*}
a+b=c\\
d-d=u
\end{gather*}
\end{frame}
\begin{frame}{多行公式按等号对齐}
\begin{align}
x &= t+\cos t +1\\
y &= 2\sin t
\end{align}
\begin{align}
x &= t+\cos t +1 &x &= 5u\\
y &= 2\sin t &y &= 6h
\end{align}
\begin{align*}
x &= t+\cos t +1\\
y &= 2\sin t
\end{align*}
\end{frame}
代码解读
\begin{gather}... \end{gather}
环境内可放多行居中对齐公式,也是默认情况下带编号,若不想带编号,做法是一样的,加一个 即可;
\\
表示公式换行,若公式后跟一个\notag
则表示该公式不参与编号;
\begin{align}...\end{align}
也可放置多行公式,里面的公式按照等号对齐,在 前方都放置一个 即可;
x &= t+\cos t +1 &x &= 5u\\
第1个和第3个 表示按照等号对齐,第二个 表示公式分隔一段间距。
效果
代码片
\begin{frame}{其他环境}
\textbf{\textcolor[rgb]{0.52,0.60,0.00}{交叉引用:}}如式\ref{eq:2}所示
\begin{align}
x &= t+\cos t +1
\label{eq:2}\\
y &= 2\sin t
\end{align}
\textcolor[rgb]{0.83,0.21,0.51}{高亮显示:}
\textcolor[rgb]{0.80,0.29,0.09}
{
\begin{align}
x = t+\cos t +1
\end{align}
}
\begin{block}{公式块}
\begin{align}
x &= t+\cos t +1 &x &= 5u\\
y &= 2\sin t &y &= 6h
\end{align}
\end{block}
\end{frame}
代码解读
交叉引用时,在该公式后面加一个\label{eq:2}
,正文引用时\ref{eq:2}
即可;
可以将公式放入高亮环境中:\textcolor[rgb]{0.80,0.29,0.09}{...}
;
还可以将公式放入块环境:\begin{block}{公式块}...\end{block}
中,按照自己审美,灵活运用。
这里补充一下之前讲的文本盒子那一块,对于颜色的更改我没有细致的讲下去,这次对于框内背景颜色的选择、框内字体的颜色统一说一下:
效果
代码片
\setbeamercolor{umbcboxes}{bg=Orange,fg=blue}
代码解读
通过在导言区加入\setbeamercolor{umbcboxes}{bg=Orange,fg=blue}
改变盒子的颜色;
bg=Orange
将框框背景颜色调至橘色,fg=blue
将框框内文本颜色调至蓝色,可根据自己需求将颜色调成自己喜欢的色号。
本次分享仅限于此了,欢迎大家点赞收藏转发!