我在 TikZ 中绘制了两幅图像,我想一次显示一个元素。具体来说,我想先显示左侧的圆圈,然后显示其周围的椭圆。然后显示右侧的圆圈,然后显示其周围的椭圆。我尝试使用 \pause、\only、\visible 以及我能找到的其他任何命令,但我无法使其工作(使用上述所有命令时都会出现编译错误)。
\documentclass{beamer}
\mode<presentation>
{
% \usetheme{default} % or try Darmstadt, Madrid, Warsaw, ...
% \usecolortheme{default} % or try albatross, beaver, crane, ...
% \usefonttheme{default} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta,
backgrounds,
calc,
decorations.pathmorphing,
patterns, positioning,
quotes,
shapes,
tikzmark
}
%\tikzstyle{every picture}+=[remember picture, overlay]
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}
%% start
\begin{document}
\section{Problem Setup, History, \& Our Result: A Snapshot}
\begin{frame}[t]{Def}
\newtcbtheorem[number within = section]{mydef}{Problem Statement}{colback=orange!20, colframe=blue!25}{ps}
\tcbset{colframe=red!75!black, colback=yellow!25!white}
\begin{mydef}{Definition}{probStatement}
Given stuff, prove:
\begin{equation*}
\tcboxmath[colframe=red!75!black, colback=yellow!25!white]
{a + b = c}
\end{equation*}
\end{mydef}
\begin{tikzpicture}
\coordinate (c) at (2.2, -0.2);
\draw[black, thick](c) circle (50 pt);
\draw[black, fill = green!10, rotate = 50, opacity = 0.25] (c) ellipse (60 pt and 10 pt);
\draw[black, fill = red!10, rotate = 30, opacity = 0.25] (c) ellipse (20 pt and 10 pt);
\draw[black, fill = blue!10, rotate = 100, opacity = 0.25] (c) ellipse (25 pt and 45 pt);
\draw[black, fill = teal!20, rotate = 110, opacity = 0.25] (c) ellipse (35 pt and 70 pt);
\draw[black, fill = magenta!30, rotate = 240, opacity = 0.25] (c) ellipse (45 pt and 65 pt);
\coordinate (cCovering) at (8.5, -0.2);
\draw[black, thick](cCovering) circle (50 pt);
\draw[black, fill = red!10, rotate = 30, opacity = 0.25] (cCovering) ellipse (20 pt and 10 pt);
\draw[black, fill = blue!10, rotate = 100, opacity = 0.25] (cCovering) ellipse (25 pt and 45 pt);
\draw[black, fill = green!10, rotate = 50, opacity = 0.25] (cCovering) ellipse (10 pt and 30 pt);
\draw[black, fill = teal!20, rotate = 50, opacity = 0.25] (cCovering) ellipse (75 pt and 20 pt);
\draw[black, fill = gray!30, rotate = 280, opacity = 0.25] (cCovering) ellipse (45 pt and 65 pt);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
有两个问题:首先,当你在有断点的幻灯片中定义一个新定理时,这会导致问题。也许最简单的解决办法是移动
\newtcbtheorem[number within = section,reset counter on overlays]{mydef}{Problem Statement}{colback=orange!20, colframe=blue!25}{ps}
在幻灯片之前。请注意reset counter on overlays
,这可避免计数器在每次休息后增加。然后您可以使用\uncover
或visible on
来自overlay-beamer-styles
库。但是,后者通过将不透明度设置为 0 来工作,并且由于您明确为椭圆设置了它,因此您可能希望将uncover
其用于椭圆。
\documentclass{beamer}
\mode<presentation>
{
% \usetheme{default} % or try Darmstadt, Madrid, Warsaw, ...
% \usecolortheme{default} % or try albatross, beaver, crane, ...
% \usefonttheme{default} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta,
backgrounds,
calc,
decorations.pathmorphing,
patterns, positioning,
quotes,
shapes,
tikzmark
}
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}
%% start
\newtcbtheorem[number within = section,reset counter on overlays]{mydef}{Problem Statement}{colback=orange!20, colframe=blue!25}{ps}
\begin{document}
\section{Problem Setup, History, \& Our Result: A Snapshot}
\begin{frame}[t]
\frametitle{Def}
\tcbset{colframe=red!75!black, colback=yellow!25!white}
\begin{mydef}{Definition}{probStatement}
Given stuff, prove:
\begin{equation*}
\tcboxmath[colframe=red!75!black, colback=yellow!25!white]
{a + b = c}
\end{equation*}
\end{mydef}
\begin{tikzpicture}
\coordinate (c) at (2.2, -0.2);
\draw[black, thick](c) circle (50 pt);
\uncover<2->{
\draw[black, fill = green!10, rotate = 50, opacity = 0.25] (c) ellipse (60 pt and 10 pt);
\draw[black, fill = red!10, rotate = 30, opacity = 0.25] (c) ellipse (20 pt and 10 pt);
\draw[black, fill = blue!10, rotate = 100, opacity = 0.25] (c) ellipse (25 pt and 45 pt);
\draw[black, fill = teal!20, rotate = 110, opacity = 0.25] (c) ellipse (35 pt and 70 pt);
\draw[black, fill = magenta!30, rotate = 240, opacity = 0.25] (c) ellipse (45 pt and 65 pt);
}
\coordinate (cCovering) at (8, -0.2);
\draw[black, thick,visible on=<3->](cCovering) circle (50 pt);
\uncover<4->{
\draw[black, fill = red!10, rotate = 30, opacity = 0.25] (cCovering) ellipse (20 pt and 10 pt);
\draw[black, fill = blue!10, rotate = 100, opacity = 0.25] (cCovering) ellipse (25 pt and 45 pt);
\draw[black, fill = green!10, rotate = 50, opacity = 0.25] (cCovering) ellipse (10 pt and 30 pt);
\draw[black, fill = teal!20, rotate = 50, opacity = 0.25] (cCovering) ellipse (75 pt and 20 pt);
\draw[black, fill = gray!30, rotate = 280, opacity = 0.25] (cCovering) ellipse (45 pt and 65 pt);
}
\end{tikzpicture}
\end{frame}
\end{document}
答案2
我发现以下代码有效:
\documentclass{beamer}
\mode<presentation>
{
% \usetheme{default} % or try Darmstadt, Madrid, Warsaw, ...
% \usecolortheme{default} % or try albatross, beaver, crane, ...
% \usefonttheme{default} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]
}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta,
backgrounds,
calc,
decorations.pathmorphing,
patterns, positioning,
quotes,
shapes,
tikzmark
}
%\tikzstyle{every picture}+=[remember picture, overlay]
\usetikzlibrary{overlay-beamer-styles}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{theorems}
\newtcbtheorem[number within = section]{mydef}{Problem Statement}{colback=orange!20, colframe=blue!25}{ps}
\tcbset{colframe=red!75!black, colback=yellow!25!white}
\usepackage{makecell} %for the thead command to break up header
%\usepackage{fourier,erewhon}
%\usepackage{amssymb, amsbsy}
\usepackage{array, booktabs, longtable}
\usepackage{graphicx}
%\usepackage[x11names, table]{xcolor}
\usepackage{caption}
%% start
\begin{document}
\section{Problem Setup, History, \& Our Result: A Snapshot}
\begin{frame}[t]{Def}
\begin{mydef}{Definition}{probStatement}
Given stuff, prove:
\begin{equation*}
\tcboxmath[colframe=red!75!black, colback=yellow!25!white]
{a + b = c}
\end{equation*}
\end{mydef}
\begin{tikzpicture}
\coordinate (c) at (2.2, -0.2);
\onslide<1->{
\draw[black, thick](c) circle (50 pt);
}
\onslide<2->{
\draw[black, fill = green!10, rotate = 50, opacity = 0.25] (c) ellipse (60 pt and 10 pt);
\draw[black, fill = red!10, rotate = 30, opacity = 0.25] (c) ellipse (20 pt and 10 pt);
\draw[black, fill = blue!10, rotate = 100, opacity = 0.25] (c) ellipse (25 pt and 45 pt);
\draw[black, fill = teal!20, rotate = 110, opacity = 0.25] (c) ellipse (35 pt and 70 pt);
\draw[black, fill = magenta!30, rotate = 240, opacity = 0.25] (c) ellipse (45 pt and 65 pt);
}
\coordinate (cCovering) at (8.5, -0.2);
\onslide<3->{
\draw[black, thick](cCovering) circle (50 pt);
}
\onslide<4->{
\draw[black, fill = red!10, rotate = 30, opacity = 0.25] (cCovering) ellipse (20 pt and 10 pt);
\draw[black, fill = blue!10, rotate = 100, opacity = 0.25] (cCovering) ellipse (25 pt and 45 pt);
\draw[black, fill = green!10, rotate = 50, opacity = 0.25] (cCovering) ellipse (10 pt and 30 pt);
\draw[black, fill = teal!20, rotate = 50, opacity = 0.25] (cCovering) ellipse (75 pt and 20 pt);
\draw[black, fill = gray!30, rotate = 280, opacity = 0.25] (cCovering) ellipse (45 pt and 65 pt);
}
\end{tikzpicture}
\end{frame}
\end{document}