在 Beamer 中选择按钮后隐藏按钮

在 Beamer 中选择按钮后隐藏按钮

我正在尝试创建一个自定义的 LaTeX Beamer Jeopardy 板。到目前为止,我遇到了两个主要问题/问题:

在@cyberSingularity 的帮助下,我能够使用 ocgx 包隐藏主游戏板上的问题按钮(请参阅下面更新的代码)。

但是,我仍然有兴趣找到一种无缝的方式,允许仅使用按钮(无滚动、箭头键、空格键等)进行导航,以便问题幻灯片对用户完全“隐藏”。

如果您能提供任何指导或支持,我们将非常感激。

\documentclass[hyperref={bookmarksdepth=1}]{beamer}
\usepackage{hyperref}
\usepackage{ocgx}

\newcommand{\home}{\hyperlink{gameboard}{\beamergotobutton{Game Board}}}

\setbeamertemplate{navigation symbols}{} %Removes default navigation symbols
\begin{document}

\section{Game Board}
\begin{frame}[label=gameboard]
\frametitle{\Large Mental Math Competition -- Spring 2013}
\begin{tabular}{ccccc}
Geometry & Wuzzles & Probability & Math Ed. & Algebra\\[2ex]
{\begin{ocg}{g100}{g100}{1}\hyperlink{Geometry100}{\beamerbutton{100}}\end{ocg}}&
{\begin{ocg}{w100}{w100}{1}\hyperlink{Wuzzles100}{\beamerbutton{100}}\end{ocg}}&
{\begin{ocg}{p100}{p100}{1}\hyperlink{Probability100}{\beamerbutton{100}}\end{ocg}}&
{\begin{ocg}{m100}{m100}{1}\hyperlink{MathEd100}{\beamerbutton{100}}\end{ocg}}&
{\begin{ocg}{a100}{a100}{1}\hyperlink{Algebra100}{\beamerbutton{100}}\end{ocg}}\\[2ex]
{\begin{ocg}{g200}{g200}{1}\hyperlink{Geometry200}{\beamerbutton{200}}\end{ocg}}&
{\begin{ocg}{w200}{w200}{1}\hyperlink{Wuzzles200}{\beamerbutton{200}}\end{ocg}}&
{\begin{ocg}{p200}{p200}{1}\hyperlink{Probability200}{\beamerbutton{200}}\end{ocg}}&
{\begin{ocg}{m200}{m200}{1}\hyperlink{MathEd200}{\beamerbutton{200}}\end{ocg}}&
{\begin{ocg}{a200}{a200}{1}\hyperlink{Algebra200}{\beamerbutton{200}}\end{ocg}}\\[2ex]
{\begin{ocg}{g300}{g300}{1}\hyperlink{Geometry300}{\beamerbutton{300}}\end{ocg}}&
{\begin{ocg}{w300}{w300}{1}\hyperlink{Wuzzles300}{\beamerbutton{300}}\end{ocg}}&
{\begin{ocg}{p300}{p300}{1}\hyperlink{Probability300}{\beamerbutton{300}}\end{ocg}}&
{\begin{ocg}{m300}{m300}{1}\hyperlink{MathEd300}{\beamerbutton{300}}\end{ocg}}&
{\begin{ocg}{a300}{a300}{1}\hyperlink{Algebra300}{\beamerbutton{300}}\end{ocg}}\\[2ex]
{\begin{ocg}{g400}{g400}{1}\hyperlink{Geometry400}{\beamerbutton{400}}\end{ocg}}&
{\begin{ocg}{w400}{w400}{1}\hyperlink{Wuzzles400}{\beamerbutton{400}}\end{ocg}}&
{\begin{ocg}{p400}{p400}{1}\hyperlink{Probability400}{\beamerbutton{400}}\end{ocg}}&
{\begin{ocg}{m400}{m400}{1}\hyperlink{MathEd400}{\beamerbutton{400}}\end{ocg}}&
{\begin{ocg}{a400}{a400}{1}\hyperlink{Algebra400}{\beamerbutton{400}}\end{ocg}}\\[2ex]
{\begin{ocg}{g500}{g500}{1}\hyperlink{Geometry500}{\beamerbutton{500}}\end{ocg}}&
{\begin{ocg}{w500}{w500}{1}\hyperlink{Wuzzles500}{\beamerbutton{500}}\end{ocg}}&
{\begin{ocg}{p500}{p500}{1}\hyperlink{Probability500}{\beamerbutton{500}}\end{ocg}}&
{\begin{ocg}{m500}{m500}{1}\hyperlink{MathEd500}{\beamerbutton{500}}\end{ocg}}&
{\begin{ocg}{a500}{a500}{1}\hyperlink{Algebra500}{\beamerbutton{500}}\end{ocg}}\\
\end{tabular}
\end{frame}


\subsection{Geometry}
\begin{frame}[label=Geometry100]{Geometry 100}
...Question(s) or Image(s) Here...
\vfill
\hideocg{g100}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Geometry200]{Geometry 200}
\hideocg{g200}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Geometry300]{Geometry 300}
\hideocg{g300}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Geometry400]{Geometry 400}
\hideocg{g400}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Geometry500]{Geometry 500}
\hideocg{g500}{\beamerbutton{Correct?}}
\home
\end{frame}

\subsection{Wuzzles}
\begin{frame}[label=Wuzzles100]{Wuzzles 100}
\hideocg{w100}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Wuzzles200]{Wuzzles 200}
\hideocg{w200}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Wuzzles300]{Wuzzles 300}
\hideocg{w300}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Wuzzles400]{Wuzzles 400}
\hideocg{w400}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Wuzzles500]{Wuzzles 500}
\hideocg{w500}{\beamerbutton{Correct?}}
\home
\end{frame}

\subsection{Probability}
\begin{frame}[label=Probability100]{Probability 100}
What is the sample space produced when two coins are flipped?
\vfill
\hideocg{p100}{\beamerbutton{Correct?}}
\home
\end{frame}
 \begin{frame}[label=Probability200]{Probability 200}
In the United States, 43\% of people wear a seat belt while driving. If two people are chosen at random, what is the probability that both of them wear a seat belt? 
\vfill
\hideocg{p200}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Probability300]{Probability 300}
In a national lottery, five numbers from 1 to 50 and one bonus number from 1 to 40 are chosen randomly. Any tickets matching four of the five numbers and the bonus number win \$250,000. What is the probability that any given player will win the \$250,000 prize?
\vfill
\hideocg{p300}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Probability400]{Probability 400}
In a shipment of 150 televisions, 9 are defective. If someone buys two televisions from that shipment, what is the probability that both are defective?
\vfill
\hideocg{p400}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Probability500]{Probability 500}
A small combination lock on a suitcase has three wheels, each labeled with the ten digits from 0 to 9. If an opening combination is a particular sequence of three digits with no repeats, what is the probability of a person guessing the right combination? (Give the solution as a fraction.)
\vfill
\hideocg{p500}{\beamerbutton{Correct?}}
\home
\end{frame}

\subsection{Math Ed.}
\begin{frame}[label=MathEd100]{Math Ed. 100}
\hideocg{m100}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=MathEd200]{Math Ed. 200}
\hideocg{m200}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=MathEd300]{Math Ed. 300}
\hideocg{m300}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=MathEd400]{Math Ed. 400}
\hideocg{m400}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=MathEd500]{Math Ed. 500}
\hideocg{m500}{\beamerbutton{Correct?}}
\home
\end{frame}

\subsection{Algebra}
\begin{frame}[label=Algebra100]{Algebra 100}
\hideocg{a100}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Algebra200]{Algebra 200}
\hideocg{a200}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Algebra300]{Algebra 300}
\hideocg{a300}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Algebra400]{Algebra 400}
\hideocg{a400}{\beamerbutton{Correct?}}
\home
\end{frame}
\begin{frame}[label=Algebra500]{Algebra 500}
\hideocg{a500}{\beamerbutton{Correct?}}
\home
\end{frame}

\end{document}

答案1

这是一个可能的解决方案,但您可能不喜欢它......

限制查看者通过按键、点击等方式更改页面将会很困难/不可能。通常,文档试图干扰查看器应用程序的正常使用并不是一个好主意,而且查看器应用程序也不太可能支持它,因为它会带来可用性问题。

因此,我的建议是将所有框架放在单独的文件中,并在单独的文件之间使用超链接。这将减少玩家“意外”以你未预料到的方式导航的可能性。

为了以这种方式将 OCG 行为与命名目标/文件链接结合起来,我求助于使用 Javascript(我尝试过结合\hyperlink\actionsocg失败了)。这意味着您将需要使用支持查看器。

因此,这里jeopardy.tex我采用循环方法来生成表格,而不是重复代码:

\documentclass{beamer}
\usepackage{ocgx}
\hypersetup{hidelinks,bookmarksdepth=1}
\usepackage{insdljs}

\setbeamertemplate{navigation symbols}{}%Removes default navigation symbols

\begin{insDLJS}[jumpTo]{jeopardy}{Jeopardy}
function jumpTo(strDest)
{
    var arrayOCGs = this.getOCGs();
    for(var i=0; arrayOCGs && i<arrayOCGs.length;i++)
    {
        if(arrayOCGs[i].name == strDest)
        {
            // if the corresponding OCG is invisible, ignore the click
            if (arrayOCGs[i].state)
            {
                //app.alert("Hello World! This is \jobname. You clicked " + strDest, 3);

                // make it invisible
                arrayOCGs[i].state=false;

                //this.gotoNamedDest(strDest);
                app.openDoc("\jobname-" + strDest + ".pdf", this);

            }
        }
    }
}
\end{insDLJS}

\newcommand*{\buttonFor}[2]{%category, number
        \begin{ocg}{#1#2}{#1#2}{1}%
            \PushButton[name=myButton#1#2,onclick={jumpTo("#1#2");}]{\beamerbutton{#2}}%
        \end{ocg}%
}

\errorcontextlines=\maxdimen

\usepackage{etoolbox}




\newcommand{\dopoints}[1]{%#1<- points
    \def\beforecellcode{}%
    \forcsvlist{\docell{#1}}{Geometry,Wuzzles,Probability,MathEd,Algebra}%
    \\[2ex]
}
\newcommand{\docell}[2]{%#1<- points, #2<- category
    \beforecellcode
    \buttonFor{#2}{#1}%
    \def\beforecellcode{&}%
}%


\begin{document}
\section{Game Board}

\begin{frame}[label=gameboard]
    \frametitle{\Large Mental Math Competition -- Spring 2013}
    \begin{Form}% needed for \PushButton
        \begin{tabular}{ccccc}
            Geometry & Wuzzles & Probability & Math Ed. & Algebra\\[2ex]
            \forcsvlist\dopoints{100,200,300,400,500}
        \end{tabular}
    \end{Form}
\end{frame}

\end{document}

不幸的是,我无法让hyperrefhidelinks选项生效PushButton

以下是jeopardy-questionbase.tex游戏问题文件的模板代码:

\documentclass{beamer}
\newcommand{\home}{\Acrobatmenu{Close}{\beamergotobutton{Game Board}}}
\newenvironment{questionslide}[2]% #1<- category, #2<- points
    {%
        \begin{frame}[environment=questionslide,fragile,label=#1#2]{#1 #2}%
    }%
    {%
        \vfill
        \home
        \end{frame}%
    }

为简洁起见,我提供的唯一游戏问题代码是Probability100。该文件应jeopardy-Probability100.tex按照我在代码中使用的预期命名方案进行调用:

\input{jeopardy-questionbase}
\begin{document}
    \begin{questionslide}{Probability}{100}
        What is the sample space produced when two coins are flipped?
    \end{questionslide}
\end{document}

不幸的是,这种方法确实意味着会有很多.tex文件在浮动,并且需要编译它们......(如果缺少任何问题,则仅意味着相应的链接将无法按预期工作,但您仍然可以测试可用的链接。)

答案2

我可以建议另一个答案。它实际上在课堂上使用危险边缘在 CTAN 上:

1)游戏板上的按钮链接到 PDF 文件的相应页面

2) 检查所有有问题的 PDF 页面(在 pageopen 动作中),用户是否点击了相应的按钮。如果没有,则返回游戏板。如果是,则等待用户回答并再次返回游戏板。

3) 请记住,如果您开始使用 javascript,则用户只能使用 Acrobat Reader。其他查看器将失效。

相关内容