# LaTex, Beamer, and Young Tableaux

I just taught myself LaTeX over the last three months for my thesis. Now I need to do a presentation and I am supposed to use beamer. I used Tikz in my thesis and would like to use it again in beamer. As much as I'd love to just cut and paste my tikzpicture into the presentation, that doesn't seem to work. Here is an example of what I used in my thesis.

\begin{tikzpicture}
\matrix (m) [
matrix of math nodes,
nodes in empty cells,
minimum width=width("8"),
] {
1 & 1 & 2 & 2 &            &   &            &   &   &   & 1 & 1 & 2 & 2 &           &     &              &   &   & 1 & 1 & 2 & 2 & \leftarrow & 3 & 1 &   & 1 & 1 & 2 & 2 & 3 & \leftarrow & 1 &   \\
2 & 3 & 3 & 4 &            &   &            &   &   &   & 2 & 3 & 3 & 4 &           &     &              &   &   & 2 & 3 & 3 & 4 &            &   &   &   & 2 & 3 & 3 & 4 &   &            &   &   \\
3 & 4 & 6 &   &            &   &            &   &   & = & 3 & 4 & 6 &   &           &     &              &   & = & 3 & 4 & 6 &   &            &   &   & = & 3 & 4 & 6 &   & &              &   & = \\
4 & 7 &   &   & \leftarrow & 5 & \leftarrow & 3 & 1 &   & 4 & 5 &   &   &            &     &                 &   &   & 4 & 5 &   &   &            &   &   &   & 4 & 5 &   &   & &              &   &   \\
&   &   &   &            &   &            &   &   &   &   &   &   &   & \leftarrow & 7 & \leftarrow 3 & 1 &   & 7 &   &   &   &           &   &   &   & 7 &   &   &   &   &            &   &   \\
} ;

\draw (m-1-1.north west) rectangle (m-1-2.south east);
\draw (m-2-4.north west) rectangle (m-2-4.south east);
\draw[Red!,line width=2] (m-1-4.north west) rectangle (m-1-4.south east);
\draw (m-1-1.north west) rectangle (m-4-1.south east);
\draw (m-1-3.north west) rectangle (m-1-3.south east);
\draw (m-3-3.north west) rectangle (m-3-3.south east);
\draw[Red!,line width=2] (m-2-3.north west) rectangle (m-2-3.south east);
\draw (m-3-1.north west) rectangle (m-3-1.south east);
\draw (m-4-2.north west) rectangle (m-4-2.south east);
\draw[Red!,line width=2] (m-3-2.north west) rectangle (m-3-2.south east);
\draw (m-1-11.north west) rectangle (m-1-11.south east);
\draw (m-1-12.north west) rectangle (m-1-12.south east);
\draw (m-1-13.north west) rectangle (m-1-13.south east);
\draw (m-2-14.north west) rectangle (m-2-14.south east);
\draw (m-2-12.north west) rectangle (m-2-12.south east);
\draw[Red!,line width=2] (m-1-14.north west) rectangle (m-1-14.south east);
\draw (m-2-11.north west) rectangle (m-2-11.south east);
\draw (m-3-13.north west) rectangle (m-3-13.south east);
\draw[Red!,line width=2] (m-2-13.north west) rectangle (m-2-13.south east);
\draw (m-3-11.north west) rectangle (m-3-11.south east);
\draw[Red!,line width=2] (m-3-12.north west) rectangle (m-3-12.south east);
\draw (m-4-11.north west) rectangle (m-4-11.south east);
\draw[Red!,line width=2] (m-4-12.north west) rectangle (m-4-12.south east);
\draw (m-1-21.north west) rectangle (m-1-21.south east);
\draw (m-1-22.north west) rectangle (m-1-22.south east);
\draw (m-1-20.north west) rectangle (m-1-20.south east);
\draw (m-2-20.north west) rectangle (m-2-20.south east);
\draw (m-2-21.north west) rectangle (m-2-21.south east);
\draw (m-2-23.north west) rectangle (m-2-23.south east);
\draw[Red!,line width=2] (m-1-23.north west) rectangle (m-1-23.south east);
\draw (m-3-22.north west) rectangle (m-3-22.south east);
\draw[Red!,line width=2] (m-2-22.north west) rectangle (m-2-22.south east);
\draw (m-3-20.north west) rectangle (m-3-20.south east);
\draw[Red!,line width=2] (m-3-21.north west) rectangle (m-3-21.south east);
\draw (m-4-20.north west) rectangle (m-4-20.south east);
\draw[Red!,line width=2] (m-4-21.north west) rectangle (m-4-21.south east);
\draw[Red!,line width=2] (m-5-20.north west) rectangle (m-5-20.south east);
\draw (m-1-28.north west) rectangle (m-1-31.south east);
\draw[Orange!,line width=2] (m-1-32.north west) rectangle (m-1-32.south east);
\draw (m-1-28.north west) rectangle (m-4-28.south east);
\draw (m-1-30.north west) rectangle (m-3-30.south east);
\draw (m-2-29.north west) rectangle (m-2-31.south east);
\draw (m-4-28.north west) rectangle (m-5-28.south east);
\draw (m-3-28.north west) rectangle (m-3-28.south east);
\draw (m-4-29.north west) rectangle (m-4-29.south east);

\end{tikzpicture}


I want to show the step-by-step progression of a bumping route from the beginning of the Robinson-Schensted insertion algorithm to the end and I would do this with using multiple slides, but I don't understand how nodes work for this or even if its what I should be using. How do I go about creating this multi-slide "animation?" Thanks

The power of tikz is that you can easily write macros for drawing regular objects like tableaux. I have some code that I wrote to do something similar. Rather than drawing thicker frames I change the background colour of the cell, but it would be easy enough to adapt my code to make thicker frames if you prefer. The main idea is to bury most of the tableaux code inside a macro so that you can "write" each tableau using a natural and easy to edit syntax like

\ShadedTableau{{1,1,2,2},{2,3,3,4},{3,4,6},{4,7}}


In your use-case you want to be able to shade certain cells. To cater for this we allow an optional argument that is a comma separated list of the coordinates for the cells that we want to shade:

\ShadedTableau[(3,0),(2,-1),(1,-2)]{{1,1,2,2},{2,3,3,4},{3,4,6},{4,7}}


The \ShadedTableau macro is not particularly complicated: it uses a tikz \foreach loop to draw the tableau cell by cell, looping over the rows, and then the entries in each row, of the tableau, which are given as the arguments to \ShadedTableau. (There are some extra bells and whistles in the macros below that I have found useful.)

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{tikz}

% tikz macro for drawing tableaux with optionally shaded nodes.
\newcount\tableauRow\newcount\tableauCol
\ifx\relax#1\relax%
\else % shade the boxes in #1
\foreach\bx in {#1} { \filldraw[blue!20]\bx+(-.5,-.5)rectangle++(.5,.5); }
\fi
\tableauRow=0
\foreach \Row in {#2} {
\tableauCol=1
\foreach\k in \Row {
\draw(\the\tableauCol,\the\tableauRow)+(-.5,-.5)rectangle++(.5,.5);
\draw(\the\tableauCol,\the\tableauRow)node{\k};
}
}
\end{tikzpicture}%
}

\begin{document}

\begin{frame}{Bumping}
\pause $\overset{\longleftarrow 5\longleftarrow 3\ 1}{=}$\quad
\pause $\overset{\longleftarrow 7\longleftarrow 3\ 1}{=}$\quad
\end{frame}

\end{document}


This produces the output:

Since you asked about "multi-slide animation", in the example above this is achieved simply using the \pause command, which "pauses" the presentation until you click a key. More complicated things are possible: see the very readable beamer manual for details.

Since it is too late to modify your drawing code, the easiest way is to add a mask over the existing drawing.

The basic structure is as follows:

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\foreach\i in{1,...,30}{
\begin{frame}

\tikz[remember picture,overlay]{
\filldraw[fill=white](current page.west)++(\i/2,-1)rectangle+(12,4)--+(0,0);
}
\transreplace
\transduration{0}
\end{frame}
}

\end{document}


PS. if you are using Adobe reader and in full screen mode, it will automatically play for you.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\def\tempamp{&}
\catcode\&13 \let&\tempamp

\foreach\i in{1,...,30}{
\begin{frame}
\centering\begin{tikzpicture}[transform canvas={scale=.6}]
\matrix (m) [
matrix of math nodes,
nodes in empty cells,
minimum width=width("8"),
] {
1 & 1 & 2 & 2 &            &   &            &   &   &   & 1 & 1 & 2 & 2 &           &     &              &   &   & 1 & 1 & 2 & 2 & \leftarrow & 3 & 1 &   & 1 & 1 & 2 & 2 & 3 & \leftarrow & 1 &   \\
2 & 3 & 3 & 4 &            &   &            &   &   &   & 2 & 3 & 3 & 4 &           &     &              &   &   & 2 & 3 & 3 & 4 &            &   &   &   & 2 & 3 & 3 & 4 &   &            &   &   \\
3 & 4 & 6 &   &            &   &            &   &   & = & 3 & 4 & 6 &   &           &     &              &   & = & 3 & 4 & 6 &   &            &   &   & = & 3 & 4 & 6 &   & &              &   & = \\
4 & 7 &   &   & \leftarrow & 5 & \leftarrow & 3 & 1 &   & 4 & 5 &   &   &            &     &                 &   &   & 4 & 5 &   &   &            &   &   &   & 4 & 5 &   &   & &              &   &   \\
&   &   &   &            &   &            &   &   &   &   &   &   &   & \leftarrow & 7 & \leftarrow 3 & 1 &   & 7 &   &   &   &           &   &   &   & 7 &   &   &   &   &            &   &   \\
} ;
\draw (m-1-1.north west) rectangle (m-1-2.south east);
\draw (m-2-4.north west) rectangle (m-2-4.south east);
\draw[red!,line width=2] (m-1-4.north west) rectangle (m-1-4.south east);
\draw (m-1-1.north west) rectangle (m-4-1.south east);
\draw (m-1-3.north west) rectangle (m-1-3.south east);
\draw (m-3-3.north west) rectangle (m-3-3.south east);
\draw[red!,line width=2] (m-2-3.north west) rectangle (m-2-3.south east);
\draw (m-3-1.north west) rectangle (m-3-1.south east);
\draw (m-4-2.north west) rectangle (m-4-2.south east);
\draw[red!,line width=2] (m-3-2.north west) rectangle (m-3-2.south east);
\draw (m-1-11.north west) rectangle (m-1-11.south east);
\draw (m-1-12.north west) rectangle (m-1-12.south east);
\draw (m-1-13.north west) rectangle (m-1-13.south east);
\draw (m-2-14.north west) rectangle (m-2-14.south east);
\draw (m-2-12.north west) rectangle (m-2-12.south east);
\draw[red!,line width=2] (m-1-14.north west) rectangle (m-1-14.south east);
\draw (m-2-11.north west) rectangle (m-2-11.south east);
\draw (m-3-13.north west) rectangle (m-3-13.south east);
\draw[red!,line width=2] (m-2-13.north west) rectangle (m-2-13.south east);
\draw (m-3-11.north west) rectangle (m-3-11.south east);
\draw[red!,line width=2] (m-3-12.north west) rectangle (m-3-12.south east);
\draw (m-4-11.north west) rectangle (m-4-11.south east);
\draw[red!,line width=2] (m-4-12.north west) rectangle (m-4-12.south east);
\draw (m-1-21.north west) rectangle (m-1-21.south east);
\draw (m-1-22.north west) rectangle (m-1-22.south east);
\draw (m-1-20.north west) rectangle (m-1-20.south east);
\draw (m-2-20.north west) rectangle (m-2-20.south east);
\draw (m-2-21.north west) rectangle (m-2-21.south east);
\draw (m-2-23.north west) rectangle (m-2-23.south east);
\draw[red!,line width=2] (m-1-23.north west) rectangle (m-1-23.south east);
\draw (m-3-22.north west) rectangle (m-3-22.south east);
\draw[red!,line width=2] (m-2-22.north west) rectangle (m-2-22.south east);
\draw (m-3-20.north west) rectangle (m-3-20.south east);
\draw[red!,line width=2] (m-3-21.north west) rectangle (m-3-21.south east);
\draw (m-4-20.north west) rectangle (m-4-20.south east);
\draw[red!,line width=2] (m-4-21.north west) rectangle (m-4-21.south east);
\draw[red!,line width=2] (m-5-20.north west) rectangle (m-5-20.south east);
\draw (m-1-28.north west) rectangle (m-1-31.south east);
\draw[orange!,line width=2] (m-1-32.north west) rectangle (m-1-32.south east);
\draw (m-1-28.north west) rectangle (m-4-28.south east);
\draw (m-1-30.north west) rectangle (m-3-30.south east);
\draw (m-2-29.north west) rectangle (m-2-31.south east);
\draw (m-4-28.north west) rectangle (m-5-28.south east);
\draw (m-3-28.north west) rectangle (m-3-28.south east);
\draw (m-4-29.north west) rectangle (m-4-29.south east);
\end{tikzpicture}
\tikz[remember picture,overlay]{
\filldraw[fill=white](current page.west)++(\i/2,-1)rectangle+(12,4)--+(0,0);
}
\transreplace
\transduration{0}
\end{frame}
}

\end{document}
`