Acabo de aprender LaTeX por mi cuenta durante los últimos tres meses para mi tesis. Ahora necesito hacer una presentación y se supone que debo usar un proyector. Usé Tikz en mi tesis y me gustaría usarlo nuevamente en Beamer. Por mucho que me encantaría simplemente cortar y pegar mi imagen tikz en la presentación, eso no parece funcionar. Aquí hay un ejemplo de lo que usé en mi tesis.
\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}
Quiero mostrar la progresión paso a paso de una ruta de choque desde el principio del algoritmo de inserción de Robinson-Schensted hasta el final y lo haría usando varias diapositivas, pero no entiendo cómo funcionan los nodos para esto o incluso si es lo que debería usar. ¿Cómo hago para crear esta "animación" de múltiples diapositivas? Gracias
Respuesta1
El poder de tikz es que puedes escribir macros fácilmente para dibujar objetos regulares como cuadros. Tengo un código que escribí para hacer algo similar. En lugar de dibujar marcos más gruesos, cambio el color de fondo de la celda, pero sería bastante fácil adaptar mi código para crear marcos más gruesos si lo prefiere. La idea principal es enterrar la mayor parte del código del cuadro dentro de una macro para que puedas "escribir" cada cuadro usando una sintaxis natural y fácil de editar como
\ShadedTableau{{1,1,2,2},{2,3,3,4},{3,4,6},{4,7}}
En su caso de uso, desea poder sombrear ciertas celdas. Para atender esto, permitimos un argumento opcional que es una lista separada por comas de las coordenadas de las celdas que queremos sombrear:
\ShadedTableau[(3,0),(2,-1),(1,-2)]{{1,1,2,2},{2,3,3,4},{3,4,6},{4,7}}
El\ShadedTableau
macro no es particularmente complicada: utiliza untikz \foreach
bucle para dibujar el cuadro celda por celda, recorriendo las filas y luego las entradas en cada fila del cuadro, que se dan como argumentos para \ShadedTableau
. (Hay algunas características adicionales en las macros siguientes que me han resultado útiles).
Usando esto con el proyector, su MWE se vería así (salte al marco del proyector en la primera lectura, porque ahí es donde están sus cuadros):
\documentclass{beamer}
\usepackage{xcolor}
\usepackage{tikz}
% tikz macro for drawing tableaux with optionally shaded nodes.
% \ShadedTableau{{1,2,3,4},{5,6,7},{8,9}} -> 1234/567/89
% \ShadedTableau[(1,-1),(2,-1),(2,0),(3,0),(4,0)]{{1,2,3,4},{5,6,7},{8,9}}
\newdimen\shadedBaseline\shadedBaseline=-4mm
\newcount\tableauRow\newcount\tableauCol
\newcommand\ShadedTableau[2][\relax]{%
\begin{tikzpicture}[scale=0.4,draw/.append style={thick,black},baseline=\shadedBaseline]
\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};
\global\advance\tableauCol by 1
}
\global\advance\tableauRow by -1
}
\end{tikzpicture}%
}
\begin{document}
\begin{frame}{Bumping}
\ShadedTableau[(4,0),(3,-1),(2,-2)]{{1,1,2,2},{2,3,3,4},{3,4,6},{4,7}}
\quad
\pause $\overset{\longleftarrow 5\longleftarrow 3\ 1}{=}$\quad
\ShadedTableau[(4,0),(3,-1),(2,-2),(2,-3)]{{1,1,2,2},{2,3,3,4},{3,4,6},{4,5}}
\qquad
\pause $\overset{\longleftarrow 7\longleftarrow 3\ 1}{=}$\quad
\ShadedTableau[(4,0),(3,-1),(2,-2),(2,-3),(1,-4)]{{1,1,2,2},{2,3,3,4},{3,4,6},{4,5},{7}}
\end{frame}
\end{document}
Esto produce la salida:
Como preguntaste sobre la "animación de varias diapositivas", en el ejemplo anterior esto se logra simplemente usando el \pause
comando, que "pausa" la presentación hasta que haces clic en una tecla. Cosas más complicadas son posibles: vea el muy legibleproyectormanual para más detalles.
Respuesta2
Dado que es demasiado tarde para modificar el código de dibujo, la forma más sencilla es agregar una máscara sobre el dibujo existente.
La estructura básica es la siguiente:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\foreach\i in{1,...,30}{
\begin{frame}
your picture
\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}
PD. Si está utilizando Adobe Reader y está en modo de pantalla completa, se reproducirá automáticamente.
\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}