也许是 beamer 中有一个 bug,在使用最小文档类时可以正常工作。
再次,以下那边的例子,并且玩过之后圈出/框出并引用一堆节点,以下操作无法按预期工作:
\documentclass[ignorenonframetext,xcolor={table,svgnames}]{beamer}
%\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,fit,positioning}
\begin{document}
\tikzstyle{every picture}+=[remember picture]
\begin{frame}
\tikzstyle{na} = [baseline=-.5ex]
\begin{tabular}{ll}
Blah & $=$ Again blah
\tikz[na] \node[coordinate] (blah) {};\\
Foo & $+$ Bar \\
Buggy & $=$
\tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (bug)
{Bug};
}
\end{tabular}
\bigskip
This is also buggy, booh \tikz[na] \node[coordinate] (booh) {};
\begin{tikzpicture}[overlay]
\path[very thick,->] (blah) edge [bend right] (bug);
\path[very thick,->] (booh) edge [bend left] (bug);
\end{tikzpicture}
\end{frame}
\end{document}
我刚刚找到了罪魁祸首,就是 ignorenonframetext 选项!!但为什么会这样呢?
答案1
问题是\tikzstyle{every picture}+=[remember picture]
位于框架之外,位于文档主体内部,因此ignorenonframetext
忽略该remember picture
部分。您可以将其发送到序言(使其成为全局)或环境内部frame
(请注意,我使用了\tikzset
而不是过时的\tikzstyle
):
\documentclass[ignorenonframetext,xcolor={table,svgnames}]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,fit,positioning}
\tikzset{every picture/.style={remember picture}}
\begin{document}
\begin{frame}
\tikzset{na/.style={baseline=-.5ex}}
\begin{tabular}{ll}
Blah & $=$ Again blah
\tikz[na] \node[coordinate] (blah) {};\\
Foo & $+$ Bar \\
Buggy & $=$
\tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (bug)
{Bug};
}
\end{tabular}
\bigskip
This is also buggy, booh \tikz[na] \node[coordinate] (booh) {};
\begin{tikzpicture}[overlay]
\path[very thick,->] (blah) edge [bend right] (bug);
\path[very thick,->] (booh) edge [bend left] (bug);
\end{tikzpicture}
\end{frame}
\end{document}