Beamer:逐个显示单元格,同时划掉一个列表

Beamer:逐个显示单元格,同时划掉一个列表

单元格中的条目需要逐个出现,同时参考表格 1 中的内容(整行)需要被删除。

%\documentclass[aspectratio=169, handout]{beamer}
\documentclass[aspectratio=169]{beamer}                 % Document class
\usepackage{subcaption}
\usepackage[english]{babel}             % Set language
\usepackage[utf8x]{inputenc}            % Set encoding
\usepackage{nicematrix,tikz}
\mode<presentation>                     % Set options
{
  \usetheme{default}                    % Set theme
  \usecolortheme{rose}              % Set colors
  \usefonttheme{default}                % Set font theme
  \setbeamertemplate{caption}[numbered] % Set caption to be numbered
  
}
\usepackage{tabularx}
\usepackage{graphicx}                   % For including figures
\usepackage{booktabs, caption}                  % For table rules
\usepackage{hyperref}                   % For cross-referencing
\usepackage{fontawesome}
\usepackage{charter} % serif
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{pdflscape,array,booktabs}
\usepackage[font=scriptsize]{caption}
\begin{document}

\setbeamertemplate{frametitle}[default][center]

\begin{frame}
    \begin{itemize}[<+|+->]
        \small
        \item[]     \tiny{\begin{table}
                \caption{Feeding table}
                \begin{tabular}{ c | c | c }
                    \toprule
                    Task & Time &Positional weight\\
                    \midrule
                    1 & 12 &70 \\
                    2 & 6 &58 \\
                    3 & 6 &31\\
                    4 & 2 &27 \\
                    5 & 2 & 20\\
                    6 &  12 & 29 \\
                    7 & 7 & 25\\
                    8 & 5 & 18\\
                    9 & 1 &18 \\
                    10 & 4 &17 \\
                    11 &  6&13 \\
                    12 &  7 &7 \\
                    \bottomrule
                \end{tabular}
            \end{table}
        }
    \item Method:
        \item From the available tasks, choose the task for which the sum of following task times is the longest.
        \vspace*{-0.2cm}
        \item[] \begin{table}
                \caption{Data picked up from feeding table}
            \centering
            \tiny
            \begin{tabular}{l | m{1cm} | m{1cm} | m{1cm} | m{1cm} | m{1cm} | m{1cm}}
                \toprule
                Station & 1 & 2 & 3 & 4 & 5 & 6 \\
                \midrule
                Tasks &\onslide<5->{1} &\onslide<6->{2,3,4} & \onslide<7->{6,5,9}& \onslide<8->{7,8} & \onslide<9->{10,11} & \onslide<10->{12} \\
                \bottomrule
            \end{tabular}
        \end{table}
    \end{itemize}   
\end{frame}
\end{document}

在此处输入图片描述

对于表格 2 中的行标有任务,从表格 1 中选取任务编号。选取任务编号时,需要删除表格 1 中对应的条目(整行)。此外,对于具有多个任务编号的单元格,条目需要逐一出现。例如:\onslide<6->{2,3,4},内容应该逐一出现,首先是 2,然后是 3,然后是 4。如何在从表格 1 填充表格 2 中的任务时同时删除表格 1(整行)中的任务?

答案1

你可以使用https://tex.stackexchange.com/a/265728/36296删除表中的行:

%\documentclass[aspectratio=169, handout]{beamer}
\documentclass[aspectratio=169]{beamer}                 % Document class
\usepackage{subcaption}
\usepackage[english]{babel}             % Set language
%\usepackage[utf8x]{inputenc}            % Set encoding
\usepackage{nicematrix,tikz}
\mode<presentation>                     % Set options
{
  \usetheme{default}                    % Set theme
  \usecolortheme{rose}              % Set colors
  \usefonttheme{default}                % Set font theme
  \setbeamertemplate{caption}[numbered] % Set caption to be numbered
  
}
\usepackage{tabularx}
%\usepackage{graphicx}                   % For including figures
\usepackage{booktabs, caption}                  % For table rules
%\usepackage{hyperref}                   % For cross-referencing
\usepackage{fontawesome}
\usepackage{charter} % serif
%\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{pdflscape,array,booktabs}
\usepackage[font=scriptsize]{caption}

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\setbeamertemplate{frametitle}[default][center]

\begin{frame}
    \begin{itemize}[<+|+->]
        \small
        \item[] \begin{table}
                \tiny
                \caption{Feeding table}
                \begin{tabular}{ c | c | c }
                    \toprule
                    Task & Time &Positional weight\\
                    \midrule
                    \tikzmark{1-start}1 & 12 &70  \tikzmark{1-stop} \\
                    \tikzmark{2-start}2 & 6 &58   \tikzmark{2-stop}\\
                    \tikzmark{3-start}3 & 6 &31   \tikzmark{3-stop}\\
                    \tikzmark{4-start}4 & 2 &27   \tikzmark{4-stop}\\
                    \tikzmark{5-start}5 & 2 & 20  \tikzmark{5-stop}\\
                    \tikzmark{6-start}6 & 12 & 29 \tikzmark{6-stop}\\
                    \tikzmark{7-start}7 & 7 & 25  \tikzmark{7-stop}\\
                    \tikzmark{8-start}8 & 5 & 18  \tikzmark{8-stop}\\
                    \tikzmark{9-start}9 & 1 &18   \tikzmark{9-stop}\\
                    \tikzmark{10-start}10 & 4 &17 \tikzmark{10-stop}\\
                    \tikzmark{11-start}11 &  6&13 \tikzmark{11-stop}\\
                    \tikzmark{12-start}12 &  7 &7 \tikzmark{12-stop}\\
                    \bottomrule
                \end{tabular}
            \end{table}
    \item Method:
        \item From the available tasks, choose the task for which the sum of following task times is the longest.
        \vspace*{-0.2cm}
        \item[] \begin{table}
                \caption{Data picked up from feeding table}
            \centering
            \tiny
            \begin{tabular}{l | m{1cm} | m{1cm} | m{1cm} | m{1cm} | m{1cm} | m{1cm}}
                \toprule
                Station & 1 & 2 & 3 & 4 & 5 & 6 \\
                \midrule
                Tasks &\uncover<+->{1} &\uncover<+->{2}\uncover<+->{,3}\uncover<+->{,4} & \uncover<+->{6}\uncover<+->{,5}\uncover<+->{,9}& \uncover<+->{7}\uncover<+->{,8} & \uncover<+->{10}\uncover<+->{,11} & \uncover<+->{12} \\
                \bottomrule
            \end{tabular}
        \end{table}
    \end{itemize}   
\begin{tikzpicture}[remember picture,overlay] 
  \draw<5-> ([yshift=.2em]pic cs:1-start) -- ([yshift=.2em]pic cs:1-stop);
  \draw<6-> ([yshift=.2em]pic cs:2-start) -- ([yshift=.2em]pic cs:2-stop);
  \draw<7-> ([yshift=.2em]pic cs:3-start) -- ([yshift=.2em]pic cs:3-stop);
  \draw<8-> ([yshift=.2em]pic cs:4-start) -- ([yshift=.2em]pic cs:4-stop);
  \draw<9-> ([yshift=.2em]pic cs:6-start) -- ([yshift=.2em]pic cs:6-stop);  
  \draw<10-> ([yshift=.2em]pic cs:5-start) -- ([yshift=.2em]pic cs:5-stop);
  \draw<11-> ([yshift=.2em]pic cs:9-start) -- ([yshift=.2em]pic cs:9-stop);  
  \draw<12-> ([yshift=.2em]pic cs:7-start) -- ([yshift=.2em]pic cs:7-stop);
  \draw<13-> ([yshift=.2em]pic cs:8-start) -- ([yshift=.2em]pic cs:8-stop);
  \draw<14-> ([yshift=.2em]pic cs:10-start) -- ([yshift=.2em]pic cs:10-stop);
  \draw<15-> ([yshift=.2em]pic cs:11-start) -- ([yshift=.2em]pic cs:11-stop);
  \draw<16-> ([yshift=.2em]pic cs:12-start) -- ([yshift=.2em]pic cs:12-stop);          
\end{tikzpicture}     
\end{frame}
\end{document}

在此处输入图片描述

答案2

这是一个使用 的解决方案nicematrix。您需要进行多次编译(因为 构建了 PGF/Tikz 节点nicematrix)。

\documentclass[aspectratio=169]{beamer}            
\usepackage[english]{babel}        

\mode<presentation>                 
{
  \usetheme{default}                
  \usecolortheme{rose}              
  \usefonttheme{default}                
  \setbeamertemplate{caption}[numbered] 
  
}

\usepackage{fontawesome}
\usepackage{charter} 
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage[font=scriptsize]{caption}

\usepackage{nicematrix,tikz}


\ExplSyntaxOn
\newcommand<> { \Strike }  
  { 
    \only#1
      {
        \tl_gput_right:Nx \g_nicematrix_code_after_tl
          { \mathslove_strike:n { \arabic { iRow } } }
      }
    \ignorespaces
  }
\cs_new_protected:Nn \mathslove_strike:n
  { \tikz \draw ([yshift=2pt]#1-1.south~west) -- ([yshift=2pt]#1-3.south~east) ; } 
\ExplSyntaxOff


% In {NiceTabular} of nicematrix, the rules drawn by "|" are 
% never broken, even when using \toprule, etc. of booktabs.
% The following column type behaves as standard "|" of {tabular}.
\newcolumntype{I}{!{\vrule}}


\begin{document}

\setbeamertemplate{frametitle}[default][center]

\begin{frame}
  \small
  \begin{table}
     \tiny
     \caption{Feeding table}
     \begin{NiceTabular}{cIcIc}
        \toprule
          Task & Time & Positional weight \\
        \midrule
          \Strike<5->   1 & 12 & 70 \\
          \Strike<6->   2 &  6 & 58 \\
          \Strike<7->   3 &  6 & 31 \\
          \Strike<8->   4 &  2 & 27 \\
          \Strike<10->  5 &  2 & 20 \\
          \Strike<9->   6 & 12 & 29 \\
          \Strike<12->  7 &  7 & 25 \\
          \Strike<13->  8 &  5 & 18 \\
          \Strike<11->  9 &  1 & 18 \\
          \Strike<14-> 10 &  4 & 17 \\
          \Strike<15-> 11 &  6 & 13 \\
          \Strike<16-> 12 &  7 &  7 \\
        \bottomrule
     \end{NiceTabular}
  \end{table}

  \begin{itemize}[<+|+->]
    \item Method:
    \item From the available tasks, choose the task for which the sum of following task times is the longest. 
  \end{itemize}   

  \uncover<3->
    {
  \begin{table}
    \caption{Data picked up from feeding table}
    \centering
    \tiny
    \begin{tabular}{l | m{1cm} | m{1cm} | m{1cm} | m{1cm} | m{1cm} | m{1cm} }
       \toprule
         Station & 1 & 2 & 3 & 4 & 5 & 6 \\
       \midrule
         Tasks &\uncover<+->{1} &\uncover<+->{2}\uncover<+->{,3}\uncover<+->{,4} & \uncover<+->{6}\uncover<+->{,5}\uncover<+->{,9}& \uncover<+->{7}\uncover<+->{,8} & \uncover<+->{10}\uncover<+->{,11} & \uncover<+->{12} \\
       \bottomrule
    \end{tabular}
  \end{table}
    }

\vfill

\end{frame}

\end{document}

上述代码的输出结果如下:

代码的主要部分是以下命令\Strike

\ExplSyntaxOn
\newcommand<> { \Strike }  
  { 
    \only#1
      {
        \tl_gput_right:Nx \g_nicematrix_code_after_tl
          { \mathslove_strike:n { \arabic { iRow } } }
      }
    \ignorespaces
  }
\cs_new_protected:Nn \mathslove_strike:n
  { \tikz \draw ([yshift=2pt]#1-1.south~west) -- ([yshift=2pt]#1-3.south~east) ; } 
\ExplSyntaxOff

该命令的\Strike作用是副作用,也就是说它在\g_nicematrix_code_after_tl提供的参数中添加代码nicematrix(它是一个内部但公开的参数),而不是直接进行排版。这就是为什么我们需要\only而不是\uncover(使用\uncover,规则将始终被绘制,因为它是一个副作用)。

相关内容