我想制作一个箭头并写一些注释,如下所示
我尝试使用以下代码
\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}
\author{Author}
\title{Presentation title}
\begin{document}
\frame{
\ft{MATERIAL IN THE UNIVERSE}
\framesubtitle{Simulations need to account for the full cosmic matter-energy content}
\begin{block}{Main ingredients of the Universe:}
\begin{itemize}
\item Dark Energy \hspace{16.3 mm} $\Rightarrow $ expansion, $a(t)$
\item Dark Matter \hspace{16.3 mm} $\Rightarrow $ collisionless fluid, interacting \\ \hspace{68 mm} via gravity
\item Baryonic Matter (`gas') $\Rightarrow $ \tikz[baseline]{\node[fill=green!20,anchor=base] (t1){(magneto)hydrodynamic};},\\ \hspace{68 mm} self-gravity
\end{itemize}
\begin{itemize}[<+-| alert@+>]
\item that is actually not enough, we need to include sub-resolution physics (cooling, star formation, feedback processes, ...) and we would like to have radiative transport as well
\tikz[na] \node[coordinate] (n1) {};
\end{itemize}
\begin{tikzpicture}[overlay]
\path[->]<3-> (n1) edge [out=0, in=-90] (t1);
\end{tikzpicture}
\end{block}
}
\end{document}
但它给了我以下错误
! 未定义的控制序列。\beamer@doifinframe ...gas') $\Rightarrow $ \tikz [baseline]{\node [fill=gre... l.185 } 错误消息顶行末尾的控制序列从未被 \def'ed。如果您拼错了它(例如,
\hobx'), type
I' 和正确的拼写(例如,`I\hbox')。否则继续,我会忘记未定义的内容。
我该如何解决这个问题?可能是什么问题?还有其他更简单的方法吗?
谢谢
答案1
您必须在选项中使用记住n1
图片t1
\tikz[remember picture] \node[coordinate] (n1) {};
代码:
\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}
\author{Author}
\title{Presentation title}
\begin{document}
\frame{
\frametitle{MATERIAL IN THE UNIVERSE}
\framesubtitle{Simulations need to account for the full cosmic matter-energy content}
\begin{block}{Main ingredients of the Universe:}
\begin{itemize}
\item Dark Energy \hspace{16.3 mm} $\Rightarrow $ expansion, $a(t)$
\item Dark Matter \hspace{16.3 mm} $\Rightarrow $ collisionless fluid, interacting \\ \hspace{68 mm} via gravity
\item Baryonic Matter (`gas') $\Rightarrow $ \tikz[baseline,remember picture]{\node[fill=green!20,anchor=base] (t1){(magneto)hydrodynamic};},\\ \hspace{68 mm} self-gravity
\end{itemize}
\begin{itemize}[<+-| alert@+>]
\item that is actually not enough, we need to include sub-resolution physics (cooling, star formation, feedback processes, ...) and we would like to have radiative transport as well
\tikz[remember picture] \node[coordinate] (n1) {};
\end{itemize}
\begin{tikzpicture}[remember picture,overlay] %% use here too
\path[draw=magenta,thick,->]<3-> ([yshift=2mm]n1.north) to [out=0, in=0,distance=1in] (t1.east);
\end{tikzpicture}
\end{block}
}
\end{document}
和tikzmark
:
\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}
\author{Author}
\title{Presentation title}
\newcommand{\tikzmark}[1]{\tikz[remember picture] \node[coordinate] (#1) {#1};}
\begin{document}
\frame{
\frametitle{MATERIAL IN THE UNIVERSE}
\framesubtitle{Simulations need to account for the full cosmic matter-energy content}
\begin{block}{Main ingredients of the Universe:}
\begin{itemize}
\item Dark Energy \hspace{16.3 mm} $\Rightarrow $ expansion, $a(t)$
\item Dark Matter \hspace{16.3 mm} $\Rightarrow $ collisionless fluid, interacting \\ \hspace{68 mm} via gravity
\item Baryonic Matter (`gas') $\Rightarrow $ \tikzmark{t1},\\ \hspace{68 mm} self-gravity
\end{itemize}
\begin{itemize}[<+-| alert@+>]
\item that is actually not enough,\tikzmark{n1} we need to include sub-resolution physics (cooling, star formation, feedback processes, ...) and we would like to have radiative transport as well
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
%\path[draw=magenta,thick,->]<3-> ([yshift=3mm]n1) to ++(0,3mm) to [out=0, in=0,distance=2.5in] (t1);
\path[draw=magenta,thick,->]<3-> ([yshift=3mm]n1) -- (t1);
\end{tikzpicture}
\end{block}
}
\end{document}
答案2
首先,正如已经说过的,需要在和remember picture
中使用,但这可以全局完成:n1
t1
\tikzstyle{every picture}+=[remember picture]
此外,带箭头的图片需要是段落的一部分,因为回答说带有覆盖层的 Tikzpicture 占用空间。下面是各种正确和错误解决方案的示例:
\documentclass[10pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
% Tests of TikZ pictures with remember picture + overlay
% under Debian/unstable on 2016-06-14 (TeX Live 2016).
\begin{document}
\tikzstyle{every picture}+=[remember picture]
%%% Frame without the arrow (expected layout)
\begin{frame}
Text \tikz[baseline] \node[coordinate] (n1) {};
Text \tikz[baseline] \node[coordinate] (t1) {};
\end{frame}
%%% Frame with an arrow - correct (TikZ picture part of a paragraph)
\begin{frame}
Text \tikz[baseline] \node[coordinate] (n1) {};
Text \tikz[baseline] \node[coordinate] (t1) {};
\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}%
\end{frame}
%%% Frame with an arrow - correct (TikZ picture part of a paragraph)
\begin{frame}
Text \tikz[baseline] \node[coordinate] (n1) {};
\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}%
Text \tikz[baseline] \node[coordinate] (t1) {};
\end{frame}
%%% Frame with an arrow - incorrect due to picture not in a paragraph
%%% The picture takes some space, slightly moving text upwards.
\begin{frame}
Text \tikz[baseline] \node[coordinate] (n1) {};
Text \tikz[baseline] \node[coordinate] (t1) {};
\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}%
\end{frame}
%%% Frame with an arrow - also incorrect: the \makebox(0,0) does not help
%%% Same problem.
\begin{frame}
Text \tikz[baseline] \node[coordinate] (n1) {};
Text \tikz[baseline] \node[coordinate] (t1) {};
\makebox(0,0){\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}}%
\end{frame}
%%% Frame with an arrow - also incorrect due to picture not in a paragraph
%%% The space taken by the picture is now between the two lines of text.
\begin{frame}
Text \tikz[baseline] \node[coordinate] (n1) {};
\makebox(0,0){\tikz[overlay]{\path[->]<1-> (n1) edge [bend left] (t1);}}%
Text \tikz[baseline] \node[coordinate] (t1) {};
\end{frame}
\end{document}