I'm using Overleaf to build a beamer presentation and wanted to add rectangles around cells in table (as described in this other question/answer by barbara beeton). Unfortunately, I get error messages and disaligned rectangles when I try to implement it in beamer, inside the frame environment.
Here it is a minimal working example using the article class:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,fit}
\begin{document}
\begin{tikzpicture}
\matrix (M) [%
matrix of nodes, column sep=1cm, row sep=1cm
]
{%
A1& B1 \\
A2& B2 \\
};
\node[draw=blue,rounded corners = 1ex,fit=(M-1-1)(M-2-1),inner sep = 0pt] {};
\end{tikzpicture}
\end{document}
Here it is a minimal working example using the beamer class:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,fit}
\begin{document}
% \begin{frame}{Frame Title}
\begin{tikzpicture}
\matrix (M) [%
matrix of nodes, column sep=1cm, row sep=1cm
]
{%
A1& B1 \\
A2& B2 \\
};
\node[draw=blue,rounded corners = 1ex,fit=(M-1-1)(M-2-1),inner sep = 0pt] {};
\end{tikzpicture}
% \end{frame}
\end{document}
However, if I uncomment the frame environment the code does not compile properly anymore. The following is the problematic code:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,fit}
\begin{document}
\begin{frame}{Frame Title}
\begin{tikzpicture}
\matrix (M) [%
matrix of nodes, column sep=1cm, row sep=1cm
]
{%
A1& B1 \\
A2& B2 \\
};
\node[draw=blue,rounded corners = 1ex,fit=(M-1-1)(M-2-1),inner sep = 0pt] {};
\end{tikzpicture}
\end{frame}
\end{document}
Thanks a lot for helping!
