下面的例子是此主题。我想根据我是否在desktop
或presentation
模式下运行来调节圆圈。我该如何定义计数器aCirc
,bCirc
以便在desktop
模式下不出现圆圈?在模式下,我可以通过将相应的计数器设置为 0 来消除一个或其他圆圈。但出于某种原因,这对模式 presentation
不起作用。desktop
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric}
\newcounter{nodemarkers}
\newcommand<>\circletext[1]{%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
#1%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-b) at (0,0){};%
\tikz[overlay,remember picture,inner sep=2pt]
\node#2[draw,ellipse,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};%
\stepcounter{nodemarkers}%
}
\newcounter{aCirc}
\newcounter{bCirc}
\setcounter{aCirc}{2}
\setcounter{bCirc}{3}
\begin{document}
\begin{frame}[<+->]
\frametitle{test}
\begin{tabular}{|ccccccc|}
\hline
\circletext<\theaCirc>{AAAAA}&
B&
C&
\circletext<\thebCirc>{BB}&
A&
B&
C\\
\hline
\end{tabular}
\end{frame}
\end{document}
答案1
我建议您使用\@ifclasswith{beamer}{desktop}{}{}
检测包选项,然后定义 TikZ 样式:
\makeatletter
\@ifclasswith{beamer}{desktop}{
\tikzset{my ellipse style/.style={draw=none}}
}{
\tikzset{my ellipse style/.style={draw, ellipse}}
}
\makeatother
笔记:
- 我不是投影仪专家,所以不确定为什么我需要
\RequirePackage{tikz}
有\tikzset
宏可用
代码:
\RequirePackage{tikz}% Need to get \tikzset for some reason
\documentclass[desktop]{beamer}
\makeatletter
\@ifclasswith{beamer}{desktop}{
\tikzset{my ellipse style/.style={draw=none}}
}{
\tikzset{my ellipse style/.style={draw, ellipse}}
}
\makeatother
\newcommand<>\circletext[1]{%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
#1%
\tikz[overlay,remember picture]
\node (marker-\arabic{nodemarkers}-b) at (0,0){};%
\tikz[overlay,remember picture,inner sep=2pt]
\node#2[my ellipse style,fit=(marker-\arabic{nodemarkers}-a.center)
(marker-\arabic{nodemarkers}-b.center)] {};%
\stepcounter{nodemarkers}%
}%
\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric}
\newcounter{nodemarkers}
\newcounter{aCirc}
\newcounter{bCirc}
\setcounter{aCirc}{2}
\setcounter{bCirc}{3}
\begin{document}
\begin{frame}[<+->]
\frametitle{test}
\begin{tabular}{|ccccccc|}
\hline
\circletext<\theaCirc>{AAAAA}&
B&
C&
\circletext<\thebCirc>{BB}&
A&
B&
C\\
\hline
\end{tabular}
\end{frame}
\end{document}