1

This question already has an answer here:

What is the problem with this code.

\begin{frame}
\frametitle{\textbf{\emph{m-way} Search Tree}}
\begin{figure}
 \centering
 \scalebox{0.4}{
\begin{tikzpicture}
  \tikzset{every matrix/.style={inner sep=-\pgflinewidth,matrix of math nodes,column sep=-\pgflinewidth,nodes={draw=red,font=\color{blue},minimum size=.75cm,anchor=center}}}
  \matrix[above] (t1)  at (0,0) {18 & 44 & 76 & 198\\};
  \matrix[below] (b1)  at (0,0) {\bullet & \times & \times & \bullet & \bullet\\};
  \matrix[above] (t21) at (-5,-4) {7 & 12\\};
  \matrix[below] (b21) at (-5,-4) {\times & \bullet & \times\\};
  \matrix[above] (t22) at (0,-4) {80 & 92 & 141\\};
  \matrix[below] (b22) at (0,-4) {\bullet & \times & \times & \bullet\\};
  \matrix[above] (t23) at (5,-4) {262\\};
  \matrix[below] (b23) at (5,-4) {\times & \bullet\\};
  \matrix[above] (t31) at (-7.5,-8) {8 & 10\\};
  \matrix[below] (b31) at (-7.5,-8) {\times & \times & \times\\};
  \matrix[above] (t32) at (-2.5,-8) {77\\};
  \matrix[below] (b32) at (-2.5,-8) {\times & \times\\};
  \matrix[above] (t33) at (2.5,-8) {148 & 151 & 172 & 186\\};
  \matrix[below] (b33) at (2.5,-8) {\times & \times & \times & \times & \times\\};
  \matrix[above] (t34) at (7.5,-8) {272 & 286 & 350\\};
  \matrix[below] (b34) at (7.5,-8) {\times & \times & \times & \times\\};
  \draw[blue] (b1-1-1.center) -- (t21-1-1.north east)
              (b1-1-4.center) -- (t22-1-3.north)
              (b1-1-5.center) -- (t23-1-1.north west)
              (b21-1-2.center) -- (t31-1-1.north east)
              (b22-1-1.center) -- (t32-1-1.north)
              (b22-1-4.center) -- (t33-1-2.north east)
              (b23-1-2.center) -- (t34-1-3.north);
\end{tikzpicture}
}
\vspace{-0.3cm} \caption{\emph{m-way} search tree}
\end{figure}

marked as duplicate by JouleV, Raaja, Werner, Stefan Pinnow, Dox Apr 15 at 8:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Welcome to TeX.SE! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. The easier it is to copy and test your code, the more likely your question will be answered and can help others in a similar situation. – thymaro Apr 15 at 5:55
1

The beamer class doesn't work well with TikZ's matrices. To make it work, you need to reset ampersand replacement to \& for example, and use \& for column separations:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}
\frametitle{\textbf{\emph{m-way} Search Tree}}
\begin{figure}
 \centering
 \scalebox{0.4}{
\begin{tikzpicture}
  \tikzset{every matrix/.style={inner sep=-\pgflinewidth,matrix of math nodes,column sep=-\pgflinewidth,nodes={draw=red,font=\color{blue},minimum size=.75cm,anchor=center},ampersand replacement=\&}}
  \matrix[above] (t1)  at (0,0) {18 \& 44 \& 76 \& 198\\};
  \matrix[below] (b1)  at (0,0) {\bullet \& \times \& \times \& \bullet \& \bullet\\};
  \matrix[above] (t21) at (-5,-4) {7 \& 12\\};
  \matrix[below] (b21) at (-5,-4) {\times \& \bullet \& \times\\};
  \matrix[above] (t22) at (0,-4) {80 \& 92 \& 141\\};
  \matrix[below] (b22) at (0,-4) {\bullet \& \times \& \times \& \bullet\\};
  \matrix[above] (t23) at (5,-4) {262\\};
  \matrix[below] (b23) at (5,-4) {\times \& \bullet\\};
  \matrix[above] (t31) at (-7.5,-8) {8 \& 10\\};
  \matrix[below] (b31) at (-7.5,-8) {\times \& \times \& \times\\};
  \matrix[above] (t32) at (-2.5,-8) {77\\};
  \matrix[below] (b32) at (-2.5,-8) {\times \& \times\\};
  \matrix[above] (t33) at (2.5,-8) {148 \& 151 \& 172 \& 186\\};
  \matrix[below] (b33) at (2.5,-8) {\times \& \times \& \times \& \times \& \times\\};
  \matrix[above] (t34) at (7.5,-8) {272 \& 286 \& 350\\};
  \matrix[below] (b34) at (7.5,-8) {\times \& \times \& \times \& \times\\};
  \draw[blue] (b1-1-1.center) -- (t21-1-1.north east)
              (b1-1-4.center) -- (t22-1-3.north)
              (b1-1-5.center) -- (t23-1-1.north west)
              (b21-1-2.center) -- (t31-1-1.north east)
              (b22-1-1.center) -- (t32-1-1.north)
              (b22-1-4.center) -- (t33-1-2.north east)
              (b23-1-2.center) -- (t34-1-3.north);
\end{tikzpicture}
}
\vspace{-0.3cm} \caption{\emph{m-way} search tree}
\end{figure}
\end{frame}
\end{document}

which outputs

enter image description here

However, the numbers are way too tiny. This is my recommended version

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}
\frametitle{\textbf{\emph{m-way} Search Tree}}
\begin{figure}
 \centering
\begin{tikzpicture}[scale=0.55]
  \tikzset{every matrix/.style={inner sep=-\pgflinewidth,matrix of math nodes,column sep=-\pgflinewidth,nodes={draw=red,font=\color{blue}\footnotesize,minimum size=.55cm,anchor=center},ampersand replacement=\&}}
  \matrix[above] (t1)  at (0,0) {18 \& 44 \& 76 \& 198\\};
  \matrix[below] (b1)  at (0,0) {\bullet \& \times \& \times \& \bullet \& \bullet\\};
  \matrix[above] (t21) at (-5,-4) {7 \& 12\\};
  \matrix[below] (b21) at (-5,-4) {\times \& \bullet \& \times\\};
  \matrix[above] (t22) at (0,-4) {80 \& 92 \& 141\\};
  \matrix[below] (b22) at (0,-4) {\bullet \& \times \& \times \& \bullet\\};
  \matrix[above] (t23) at (5,-4) {262\\};
  \matrix[below] (b23) at (5,-4) {\times \& \bullet\\};
  \matrix[above] (t31) at (-7.5,-8) {8 \& 10\\};
  \matrix[below] (b31) at (-7.5,-8) {\times \& \times \& \times\\};
  \matrix[above] (t32) at (-2.5,-8) {77\\};
  \matrix[below] (b32) at (-2.5,-8) {\times \& \times\\};
  \matrix[above] (t33) at (2.5,-8) {148 \& 151 \& 172 \& 186\\};
  \matrix[below] (b33) at (2.5,-8) {\times \& \times \& \times \& \times \& \times\\};
  \matrix[above] (t34) at (7.5,-8) {272 \& 286 \& 350\\};
  \matrix[below] (b34) at (7.5,-8) {\times \& \times \& \times \& \times\\};
  \draw[blue] (b1-1-1.center) -- (t21-1-1.north east)
              (b1-1-4.center) -- (t22-1-3.north)
              (b1-1-5.center) -- (t23-1-1.north west)
              (b21-1-2.center) -- (t31-1-1.north east)
              (b22-1-1.center) -- (t32-1-1.north)
              (b22-1-4.center) -- (t33-1-2.north east)
              (b23-1-2.center) -- (t34-1-3.north);
\end{tikzpicture}
\vspace{-0.3cm} \caption{\emph{m-way} search tree}
\end{figure}
\end{frame}
\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.