![使用 tcolorbox 时如何在两个不同的幻灯片中固定方程的位置?](https://linux22.com/image/443176/%E4%BD%BF%E7%94%A8%20tcolorbox%20%E6%97%B6%E5%A6%82%E4%BD%95%E5%9C%A8%E4%B8%A4%E4%B8%AA%E4%B8%8D%E5%90%8C%E7%9A%84%E5%B9%BB%E7%81%AF%E7%89%87%E4%B8%AD%E5%9B%BA%E5%AE%9A%E6%96%B9%E7%A8%8B%E7%9A%84%E4%BD%8D%E7%BD%AE%EF%BC%9F.png)
我正在尝试使方程式动起来。以下是我所做的。
\documentclass[9pt,final,leg,aspectratio=169,landscape]{beamer}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[absolute,overlay]{textpos}
\usepackage[skins,theorems]{tcolorbox}
\tcbset{highlight math style={enhanced,
colframe=red,colback=white,arc=0pt,boxrule=0.75pt}}
\begin{document}
\begin{frame}
\begin{itemize}
\item \textbf{Governing Equations:}\vspace{1.5ex}
\begin{itemize}
\item Mass continuity:
\begin{overprint}
\onslide<1>
\begin{equation}
\small{\frac{d}{dz} (\rho u) \; + \; 2 \rho V \; = \; 0 }
\end{equation}\vspace{1.5ex}
\item Radial momentum:
\begin{equation}
\small{\rho u\frac{dV}{dz} \; + \; \rho V^2 \; = \; -\Lambda \; + \; \frac{d}{dz} \left( \mu \frac{dV}{dz}\right) }
\end{equation}
\onslide<2>
\begin{equation}
\tcbset{highlight math/.append style={left=-1.35mm,right=-1mm,top=0mm,bottom=0mm}}
\small{\frac{d}{dz} (\rho u) \; + \; 2 \rho \underset{\let\scriptstyle\textstyle
\substack{v/r}}{\tcbhighmath{V}} \; = \; 0 }
\end{equation}\vspace{1.5ex}
\item Radial momentum:
\begin{equation}
\tcbset{highlight math/.append style={left=-1mm,right=-1mm,top=0mm,bottom=0mm}}
\small{\rho u\frac{dV}{dz} \; + \; \rho V^2 \; = \; -\underset{\let\scriptstyle\textstyle
\substack{\frac{1}{r} \frac{dp}{dr}}}{\tcbhighmath{\Lambda}} \; + \; \frac{d}{dz} \left( \mu \frac{dV}{dz}\right) }
\end{equation}
\end{overprint}
\end{itemize}
\end{itemize}
\end{frame}
\end{document}
但事实上,问题是当我添加方框来描述某些术语时,方程的位置会发生变化。但我希望方程在两张幻灯片中的位置保持不变,尽管在它们周围添加了额外的细节。
答案1
您可以使用该hf-tikz
包:
\documentclass[9pt,final,leg,aspectratio=169,landscape]{beamer}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[absolute,overlay]{textpos}
\usepackage[skins,theorems]{tcolorbox}
\tcbset{highlight math style={enhanced,
colframe=red,colback=white,arc=0pt,boxrule=0.75pt}}
\usetikzlibrary{overlay-beamer-styles}
\usepackage[beamer,customcolors]{hf-tikz}
\hfsetfillcolor{white}
\hfsetbordercolor{red}
\tikzset{h1/.style={
disable rounded corners=true,
above left offset={-0.1,0.4},
below right offset={0.1,-0.05},
},
}
\begin{document}
\begin{frame}
\begin{itemize}
\item \textbf{Governing Equations:}\vspace{1.5ex}
\begin{itemize}
\item Mass continuity:
\begin{equation}
\small{\frac{d}{dz} (\rho u) \; + \; 2 \rho \underset{\let\scriptstyle\textstyle
\visible<2->{\substack{v/r}}}{\tikzmarkin<2->[h1]{a1}V\tikzmarkend{a1}} \; = \; 0 }
\end{equation}\vspace{1.5ex}
\item Radial momentum:
\begin{equation}
\small{\rho u\frac{dV}{dz} \; + \; \rho V^2 \; = \; -\underset{\let\scriptstyle\textstyle
\substack{\visible<2->{\frac{1}{r} \frac{dp}{dr}}}}{\tikzmarkin<2->[h1]{a2}\Lambda\tikzmarkend{a2}} \; + \; \frac{d}{dz} \left( \mu \frac{dV}{dz}\right) }
\end{equation}
\end{itemize}
\end{itemize}
\end{frame}
\end{document}