![Beamer 内容默认顶部边距-如何抑制?](https://linux22.com/image/320665/Beamer%20%E5%86%85%E5%AE%B9%E9%BB%98%E8%AE%A4%E9%A1%B6%E9%83%A8%E8%BE%B9%E8%B7%9D-%E5%A6%82%E4%BD%95%E6%8A%91%E5%88%B6%EF%BC%9F.png)
如何抑制投影仪框架内容框的顶部边距?
这是我的代码
\documentclass{beamer}
\usepackage{beamerthemesplit} % new
\usepackage{eqnarray,amsmath, amsfonts, amssymb, cancel}
\usepackage{tcolorbox}
\usepackage{color,xcolor }
\tcbset{%
noparskip,
colback=gray!10, %background color of the box
colframe=gray!40, %color of frame and title background
coltext=black, %color of body text
coltitle=black, %color of title text
fonttitle=\bfseries,
alerted/.style={coltitle=red,
colframe=gray!40},
example/.style={coltitle=black,
colframe=green!20,
colback=green!5},
}
\addtobeamertemplate{frametitle}{}{\vspace{-0.2 cm}}
\newcommand{\disponslide}[2]{%
\alt<#1>{#2}{\phantom{#2}}}
\begin{document}
\begin{frame}[t]
\frametitle{Expansion}
\begin{tcolorbox}
For all real numbers $a,b \in \mathbb{R}$,
\begin{align*}
&(a+b)^2 = a^2 + 2ab + b^2&&\\
&(a+b)(a-b) = a^2 - 2ab + b^2&&
\end{align*}
\end{tcolorbox}
\begin{align*}
(a+b)^2&= (a+b)(a+b)\\
&= a^2+ab+ba+b^2\\
&= a^2+2ab+b^2 \quad\text{(since ba=ab)}\\
(a+b)(a-b)&= a^2-ab+ba-b^2 \\
&= a^2-b^2 \quad\text{(since ba=ab)}
\end{align*}
\end{frame}
\end{document}
参见下文,公式框和方程式之间存在明显的差距。我从未在公式框后指定换行符,但 Latex 仍然会插入几行换行符。
提前致谢。
答案1
您必须使用[nobeforeafter]
选项来tcolorbox
取消那些顶部和底部空格,并且该框将放置在没有上下空格的段落中。
\documentclass{beamer}
\usepackage{beamerthemesplit} % new
\usepackage{eqnarray,amsmath, amsfonts, amssymb, cancel}
\usepackage{tcolorbox}
\usepackage{color,xcolor }
\tcbset{%
noparskip,
colback=gray!10, %background color of the box
colframe=gray!40, %color of frame and title background
coltext=black, %color of body text
coltitle=black, %color of title text
fonttitle=\bfseries,
alerted/.style={coltitle=red,
colframe=gray!40},
example/.style={coltitle=black,
colframe=green!20,
colback=green!5},
}
\addtobeamertemplate{frametitle}{}{\vspace{-0.2 cm}}
\newcommand{\disponslide}[2]{%
\alt<#1>{#2}{\phantom{#2}}}
\begin{document}
\begin{frame}[t]
\frametitle{Expansion}
\begin{tcolorbox}[nobeforeafter]
For all real numbers $a,b \in \mathbb{R}$,
\begin{align*}
&(a+b)^2 = a^2 + 2ab + b^2&&\\
&(a+b)(a-b) = a^2 - 2ab + b^2&&
\end{align*}
\end{tcolorbox}
\begin{align*}
(a+b)^2&= (a+b)(a+b)\\
&= a^2+ab+ba+b^2\\
&= a^2+2ab+b^2 \quad\text{(since ba=ab)}\\
(a+b)(a-b)&= a^2-ab+ba-b^2 \\
&= a^2-b^2 \quad\text{(since ba=ab)}
\end{align*}
\end{frame}
\end{document}
您可以使用键before skip
、after skip
等beforeafter skip
来更好地控制它们。