Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am attempting to create a custom LaTeX Beamer Jeopardy board. So far I've run into two major questions/issues:

With help from @cyberSingularity, I was able to hide the question button on the main game board using the ocgx package (Please see the updated code below).

However, I am still interested in finding a seemless way to allow navigation using ONLY the buttons (no scrolling, arrow keys, spacebar, etc.) so that the question slides are completely "hidden" from the user.

Any guidance or support you can offer would be much appreciated.

\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}
share|improve this question
    
I was looking to keep the bookmark to only the first frame; I'm trying to force all navigation through the buttons on the slides. –  MathRulesTheWorld Jan 9 '13 at 22:13
    
@cyberSingularity Thank you very much for the comments. To clarify, bookmarksdepth=1 seems to show the game board only (and not the unlying subsections). Do you have any thoughts on how to change the color of the buttons on the game board frame after they have been selected? –  MathRulesTheWorld Jan 9 '13 at 22:46
    
For the ocgx approach I had in mind, one would need to combine \hyperlink and \actionsocg. I have tried but I don't know enough about the PDF specification to successfully combine /A << /S/SetOCGState /State [/Toggle \csname OCGpdfobjGeometry100\endcsname] >> and /A<</S/GoTo/D(Geometry1000)>>. –  cyberSingularity Jan 10 '13 at 0:53
    
@cyberSingularity I was able to tackle the question of making the questions that have been answered dissapear by adding a "Correct" button to the answer frames (using your idea via the ocgx package). I would like to share the code, but it's too long for me to post to the comment. –  MathRulesTheWorld Jan 11 '13 at 21:02
    
It's fine, even encouraged, to go ahead and answer your own question. However, if there is still some part that is unsolved, you might like to edit your achievements into your question instead, and make it clear what you would still like help with. –  cyberSingularity Jan 11 '13 at 21:15
show 1 more comment

2 Answers

up vote 1 down vote accepted

Here's a possible solution, but you may not like it...

Restricting the viewer from changing pages through keypresses, clicks etc will be difficult/impossible. Generally, it is not a good idea for a document to try to interfere with normal use of the viewer application, and viewer applications are unlikely to support it too, as it presents usability issues.

Therefore, my suggestion is to have all the frames in separate files and to use hyperlinks between the separate files. This will make it less likely that a player "accidentally" navigates in a way you were not anticipating.

In order to combine the OCG behaviour with the named destination/file links in this approach, I have resorted to using Javascript (my attempts with combining \hyperlink and \actionsocg failed). One implication that is you will need to use a supporting viewer.

So, here's jeopardy.tex, where I have taken a looping approach to generate the table instead of repeating the code:

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

Unfortunately, I could not get hyperref's hidelinks option to take effect for the PushButton.

Here's jeopardy-questionbase.tex, the template code for the game question files:

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

For brevity, the only game question code I have presented is for Probability100. The file should be called jeopardy-Probability100.tex to conform with the expected naming scheme I have used in the code:

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

Unfortunately, this approach does mean having a lot of .tex files floating around, and needing to compile them all too... (If any questions are missing, it just means that the corresponding links will not work as expected, but you will still be able to test those that are available.)

share|improve this answer
    
After reading through what you've put together, I'm really very intrigued! Thank you for the ideas, comments, and code! I think everything will come together very nicely as a direct result of your support. –  MathRulesTheWorld Jan 14 '13 at 18:38
add comment

I can suggest another answer. It is in fact used in the class jeopardy.sty on CTAN:

1) buttons from gameboard are links to the corresponding pages of the PDF file

2) all PDF pages with questions check (in pageopen action), wheter the user clicked the corresponding button. If not, return to the gamboard. If yes, wait for user answer and the return to gameboard again.

3) Rememeber, that if you start to use javascripts, the user is restricted to Acrobat Reader. Alternative viewers fail.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.