我本想将箭头指向 $A = B$,但箭头却从幻灯片外面伸出来了。这是为什么?代码如下
\documentclass[10pt,xcolor={dvipsnames}]{beamer}
\mode<article> % only for the article version
{
\usepackage{fullpage}
\usepackage{hyperref}
}
\mode<presentation>
{
%\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\setbeamercovered{transparent}
\usefonttheme{serif}
\usecolortheme{crane}
}
\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
\usepackage[latin1]{inputenc}
\usepackage{colortbl}
\usepackage{amstext,amssymb,amsmath,amsfonts,amsthm,amsbsy}
\usepackage{tikz}
\setbeamercovered{dynamic}
\setbeamertemplate{items}[circle]
\begin{document}
\begin{frame}
My equation:
\begin{gather*}
A = B \tikz[remember picture, overlay, baseline=-.5ex] \node (n1) {};
\qquad \tikz[baseline]{
\node[fill=blue!20,opacity=.6,anchor=base] (t1) {$\substack{\text{{\tiny{\color{blue}This is}}} \\ \text{{\tiny{\color{blue}my equation}}}}$};}
\begin{tikzpicture}[overlay]
\path[->,blue,opacity=.6]<1-> (n1) edge [] (t1);
\end{tikzpicture}
\end{gather*}
\end{frame}
\end{document}
答案1
如果您想在不同的 tikz 图片之间使用节点,则需要该remember picture
选项。
话虽如此:
您可以
t1
大大简化节点。使用数学模式将文本堆叠在一起似乎非常麻烦。你真的应该清理一下你的前言。许多软件包都已过时,每次编译后 .log 文件都会告诉你这一点。另外,不需要加载所有 ams* 软件包,因为 beamer 会自动执行此操作。
不确定这是您的实际图像还是只是一个简短的示例,但我认为在一张图中绘制所有三个组件会容易得多,然后 tikz 可以为您正确定位元素。
你可能还想看看 tikzmarks 库
\documentclass[10pt,xcolor={dvipsnames,table}]{beamer}
\mode<article> % only for the article version
{
\usepackage{fullpage}
\usepackage{hyperref}
}
\mode<presentation>
{
%\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\setbeamercovered{transparent}
\usefonttheme{serif}
\usecolortheme{crane}
}
%\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
%\usepackage[latin1]{inputenc}
%\usepackage{colortbl}
%\usepackage{amstext,amssymb,amsmath,amsfonts,amsthm,amsbsy}
\usepackage{tikz}
\setbeamercovered{dynamic}
\setbeamertemplate{items}[circle]
\begin{document}
\begin{frame}
My equation:
\begin{gather*}
A = B
\tikz[remember picture, overlay, baseline=-.5ex] \node (n1) {};
\qquad
\tikz[baseline=0.5ex,remember picture]{
\node[fill=blue!20,opacity=.6,anchor=base,align=center,font=\color{blue}\tiny] (t1) {This is\\ my equation};
}
\begin{tikzpicture}[overlay,remember picture]
\draw<1->[->,blue,opacity=.6] (n1) -- (t1);
\end{tikzpicture}
\end{gather*}
\end{frame}
\end{document}
答案2
如果问题仅在于在方程中添加带有两行文本的彩色节点,那么请尝试以下(简单)建议:
\documentclass[10pt,xcolor={dvipsnames,table}]{beamer}
\mode<article> % only for the article version
{
\usepackage{fullpage}
\usepackage{hyperref}
}
\mode<presentation>
{
\setbeamertemplate{background canvas}[vertical shading][bottom=red!10,top=blue!10]
\setbeamercovered{transparent}
\usefonttheme{serif}
\usecolortheme{crane}
\setbeamercovered{dynamic}
\setbeamertemplate{items}[circle]
}
\usepackage{tikz}
\begin{document}
\begin{frame}
My equation:
\[
A = B
\quad\tikz[baseline=-0.5ex] \draw[blue, ->, shorten >=3pt] (0,0) -- ++ (1,0)
node[fill=blue!20,align=center,font=\tiny, right]
{This is\\ my equation};
\]
\end{frame}
\end{document}