LaTex、Beamer 和 Young Tableaux

LaTex、Beamer 和 Young Tableaux

过去三个月,我刚刚自学了 LaTeX,用于我的论文。现在我需要做一个演示,我应该使用 beamer。我在论文中使用了 Tikz,并希望在 beamer 中再次使用它。尽管我很想将我的 tikzpicture 剪切并粘贴到演示文稿中,但这似乎行不通。这是我在论文中使用的一个示例。

\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}

我想展示从 Robinson-Schensted 插入算法的开始到结束的碰撞路线的逐步进展,我会使用多张幻灯片来实现这一点,但我不明白节点是如何工作的,甚至不知道我是否应该使用它。我该如何创建这个多幻灯片“动画”?谢谢

答案1

tikz 的强大之处在于,您可以轻松编写宏来绘制常规对象(如 tableaux)。我编写了一些代码来执行类似操作。我更改了单元格的背景颜色,而不是绘制更粗的框架,但如果您愿意,可以很容易地调整我的代码以制作更粗的框架。主要思想是将大部分 tableaux 代码隐藏在宏中,这样您就可以使用自然且易于编辑的语法“编写”每个 tableau,例如

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

在您的用例中,您希望能够为某些单元格着色。为了满足此要求,我们允许一个可选参数,该参数是要着色的单元格的坐标的逗号分隔列表:

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

这个\ShadedTableau宏并不是特别复杂:它使用一个蒂克兹 \foreach循环逐个单元格地绘制 tableau,循环遍历行,然后遍历 tableau 的每一行中的条目,这些条目作为 的参数给出\ShadedTableau。(下面的宏中有一些额外的花哨功能,我发现它们很有用。)

将它与 beamer 一起使用,您的 MWE 看起来会像这样(第一次阅读时跳到 beamer 框架,因为您的画面就在那里):

\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}

输出结果如下:

在此处输入图片描述

既然你问的是“多幻灯片动画”,在上面的例子中,这可以通过使用命令来实现\pause,该命令会“暂停”演示文稿,直到你单击某个键。更复杂的事情是可能的:请参阅非常易读的投影机手册了解详情。

答案2

由于修改绘图代码为时已晚,最简单的方法是在现有绘图上添加遮罩。

基本结构如下:

\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}

PS. 如果您使用 Adob​​e Reader 并且处于全屏模式,它将自动为您播放。

\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}

相关内容