4.2 (Optional)Explanations of the Template.
- Load packages.
- Define four colorboxes: SubjectBox, PrizeBox, QuestionHeadFoot, TextArea.
- Define four commands:
\newrow
,\header
,\footer
,\content
.
4.2.1 Load Packages
- The arrayjobx package has the
\newarray
and\readarray
commands to conveniently store a list of strings so that each string within the list can be conveniently summoned. - The tcolorbox package offers the
\newcolorbox
command to set up the colored boxes in the jeopardy game. - The ocgx package (Optional Content Group) provides the
ocg
environment to control the visibility of the prize tag in the jeopardy game.
4.2.2 Colorboxes.
- Define Colorboxes for suject title and prizes.
\newtcolorbox{SubjectBox}{
colback=gray!85, % Background color is 85 percent gray.
colframe=white, % The color of the box frame.
nobeforeafter, % Allow boxes align horizontally on the same row
arc=0pt, % Round the corners of the box. Zero means squared corners.
boxrule=.4pt, % The thickness of the box frame.
halign=center, % Center text horizontally.
valign=center, % Center text vertically.
width=0.4\textwidth, % Box width is 40 percent of the text width.
height=0.12\textheight % Box height is 12 percent of the text height, i.e., 8 rows
}
\newtcolorbox{PrizeBox}{
colupper=white, % Text color. (In a colorbox, by default, there are upper and lower parts.)
colback=orange,
colframe=white,
nobeforeafter,
arc=0pt,
boxrule=.4pt,
halign=center,
valign=center,
width=.2\textwidth, % 3 prize boxes plus 1 subject box occupy a full line.
height=0.12\textheight % 8 rows.
}
- Define the colorbox for header and footer.
\newtcolorbox{QuestionHeadFoot}{
sidebyside, % By default, divide a colorbox into left and right region
colback=orange,
before=\vskip-.2ex, % Remove the top padding
after=0ex, % Set bottom padding to 0
arc=0pt,
boxrule=.4pt,
colframe=white,
center upper, % Left region text centerred. (Because of sidebyside, upper means left.)
center lower, % Right region text centerred. (Because of sidebyside, lower means right)
colupper=white,
collower=white,
valign=center,
fontupper=\LARGE\bfseries,
fontlower=\LARGE\bfseries,
width=\textwidth,
height=.15\paperheight
}
- Define the colorbox for question content.
4.2.3 New Commands
- The
\newrow
command creates four boxes for a single row: one subject box and three prize boxes. It requires two arguments: (#1) Subject title; (#2) a sequential number for the subject. The codes
- create a subject box;
- use a for-loop to create three prize boxes. A hyperlink is displayed in each prize box, which links to the page of the specific question. The
ocg
environment takes three arguments. The second argument is the internal ID and the third is the visibility (1 for visible and 0 for invisible).
\newarray\scores % Create a new array \scores
\readarray{scores}{100&200&400} % Load the prize values to \scores
\newcommand{\newrow}[2]{
\begin{SubjectBox}
#1
\end{SubjectBox}% <-- NEVER REMOVE THIS PERCENT SIGN! It allows the color boxes sit side by side.
\foreach \i in {1,2,3}{% <-- NEVER REMOVE THIS PERCENT SIGN! It allows the color boxes sit side by side.
\begin{PrizeBox}
\begin{ocg}{s#2-\i}{s#2-\i}{1} %{PDF label}{internal reference label}{visibility}
\hyperlink{s#2-\i}{\scores(\i)}
\end{ocg}
\end{PrizeBox}% <-- NEVER REMOVE THIS PERCENT SIGN! It allows the color boxes sit side by side.
}
}
- The
header
andfooter
commands built the header and footer, respectively.\tcblower
is the dashed segmentation line between the left and right region of theQuestionHeadFoot
colorbox.
- Header uses the QuestionHeadFoot colorbox and requires two arguments: (#1) subject title; (#2) prize.
- Subject title is displayed on the left.
- Prize is displayed on the right.
- Footer uses the QuestionHeadFoot colorbox and requires one argument: (#1) the prizebox/ocg internal ID.
- Question and answer links are displayed on the left.
- Done button (remove the prize from homepage) and home button (go back to homepage) are displayed on the right.
\newcommand{\header}[2]{
\begin{QuestionHeadFoot}
#1 \tcblower #2
\end{QuestionHeadFoot}
}
\newcommand{\footer}[1]{
\begin{QuestionHeadFoot}
\hyperlink{question#1}{Question} \\ \hyperlink{answer#1}{Answer} \tcblower
\hideocg{#1}{Done!} \\ \hyperlink{home}{Home}
\end{QuestionHeadFoot}
}
- The
\content
command creates a question and answer page. It takes four arguments: (#1) Prizebox/ocg internal ID; (#2) subject title; (#3) prize; (#4) question and answer.
\hypertarget{reference tag}{}
creates anchors at the page.<1>
and<2>
are beamer sequential tags for animation flow-control. They represent two sequential items on the same beamer page.
\newcommand{\content}[4]{
\begin{frame}
\hypertarget<1>{question#1}{} % Make an anchor. Land here when the Question button is clicked.
\hypertarget<2>{answer#1}{} % Make an anchor. Land here when the Answer button is clicked.
\hypertarget{#1}{} % Make an anchor. Land here when the prize is clicked on the homepage.
\header{#2}{#3} % Make header.
#4 % Add question on part <1> and answer on part <2>.
\footer{#1} % Make footer.
\end{frame}
}