I would like to create a callout inside my slides. I'm not an expert of tikz
, however I find something online.
\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}
there are two problems here
1) there is a rectangle inside the callout but it has rounded corner, like it has inherited them from the callout shape. I would like to have "square" corners
2) that definition of \tikzmarkinside
works but maybe is not so elegant
can you help me?
P.S.: I know that I could use \includegraphics
and include a pre-compiled image of my rectangle but I would like to do all at once.
Best Answer
You should avoid nesting Tikz pictures. Instead you can draw the callout and the rectangle in the same (
overlay
) picture. That will also fix the problem with rounded corners.EDIT
With a more complicated structure inside the callout I would use a scope to separate it from the rest. The reference point inside the scope is the lower left corner of the callout.