如何抑制投影仪框架内容框的顶部边距?
这是我的代码
\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
来更好地控制它们。