我想在幻灯片中创建一个标注。我不是这方面的专家tikz
,但我在网上找到了一些东西。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,calc,shadows,decorations.pathmorphing,decorations.pathreplacing,tikzmark}
\newcommand{\tikzmarkinside}[1]{\tikz[overlay,remember picture,baseline=-0.5ex] \node (#1) {};}
\begin{document}
\begin{frame}
\begin{itemize}
\item a\tikzmarkinside{first}\pause
\item b\pause
\item c\pause
\end{itemize}
\tikz[remember picture, overlay]\node[align=center, fill=cyan!20,opacity=0.85, text width=4.2cm, rounded corners,
draw,rectangle callout,anchor=pointer,callout absolute pointer=(first.south),
below right= 1 and 1]
at (first) {
\begin{minipage}[t][2cm][t]{4cm}
\begin{tikzpicture}
\draw [fill=orange] (1,1) rectangle (2,2);
\end{tikzpicture}
\end{minipage}
};
\end{frame}
\end{document}
这里有两个问题 1) 标注内部有一个矩形,但它有圆角,就像是从标注形状继承下来的一样。我希望有“方形”角 2) 这种定义\tikzmarkinside
有效,但可能不太优雅
你能帮助我吗?
附言:我知道我可以使用\includegraphics
并包含我的矩形的预编译图像,但我想一次性完成。
答案1
您应该避免嵌套 Tikz 图片。相反,您可以在同一个 () 图片中绘制标注和矩形overlay
。这也可以解决圆角问题。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,calc,shadows,decorations.pathmorphing,decorations.pathreplacing,tikzmark}
\newcommand{\tikzmarkinside}[1]{\tikz[overlay,remember picture,baseline=-0.5ex] \node (#1) {};}
\begin{document}
\begin{frame}
\begin{itemize}
\item a\tikzmarkinside{first}\pause
\item b\pause
\item c\pause
\end{itemize}
\begin{tikzpicture}[remember picture, overlay]
\node[align=center, fill=cyan!20,opacity=0.85, text width=4.2cm, rounded corners,
draw,rectangle callout,anchor=pointer,callout absolute pointer=(first.south),
below right= 1 and 1,
minimum height=5em]
(TheBubble) at (first) {};
\draw[fill=orange] ($(TheBubble.north west)+(0.2,-0.2)$) rectangle +(1,-1);
\end{tikzpicture}
\end{frame}
\end{document}
编辑
如果标注内部的结构更复杂,我会使用示波器将其与其余部分分开。示波器内的参考点是标注的左下角。
\begin{tikzpicture}[remember picture, overlay]
\node[align=center, fill=cyan!20,opacity=0.85, text width=4.2cm, rounded corners,
draw,rectangle callout,anchor=pointer,callout absolute pointer=(first.south),
below right= 1 and 1,
minimum height=7em]
(TheBubble) at (first) {text inside the callout. It behaves as normal text.
\begin{itemize}
\item Test
\item New test
\end{itemize}
};
%\draw[fill=orange] ($(TheBubble.north west)+(0.2,-0.2)$) rectangle +(1,-1);
\begin{scope}[shift={($(TheBubble.south west) +(0.2,0.2)$)}]
\draw[fill=orange] (0,1) rectangle +(1,1);
\draw[->] (2,0) -- +(0,2) node[left]{$y$};
\draw[->] (2,0) -- +(1.5,0) node[right]{$x$};
\draw[smooth,xshift=2cm] plot coordinates {(0,0)(0.5,1)(1,1.5)(1.5,0.5)};
\end{scope}
\end{tikzpicture}