% -*- coding: utf-8 -*-

\documentclass[12pt,plain,math=most]{randexam}
\geometry{b5paper,margin=2cm}

\newcommand*{\myversion}{2024F}
\newcommand*{\mydate}{\the\year-\mylpad\month-\mylpad\day}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}

\cfoot{\small\thepage}

\setlength{\parindent}{0pt}
\setlength{\parskip}{7pt plus 1pt minus 1pt}

\usepackage{arevtext}
\usepackage{iftex}
\usepackage{ninecolors}
\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  urlcolor=blue3,
  linkcolor=blue3,
}

\renewcommand\familydefault{\sfdefault}

\renewcommand{\baselinestretch}{1}
\renewcommand{\arraystretch}{1.3}

\usepackage{tabularx}
\usepackage{booktabs}

\usepackage{fancyvrb}

\DefineVerbatimEnvironment{code}{Verbatim}{%
  formatcom=\color{blue!50!red}%
}

\usepackage{codehigh}

\NewDocumentCommand\mypkg{m}{\textcolor{blue3}{\mbox{#1}}}
\NewDocumentCommand\myopt{m}{\textcolor{yellow3}{\mbox{#1}}}
\NewDocumentCommand\mycmd{m}{\textcolor{green3}{\ttfamily\fakeverb{#1}}}
\NewDocumentCommand\myenv{m}{\textcolor{green3}{\ttfamily#1}}
\NewDocumentCommand\myfile{m}{\textcolor{purple3}{\mbox{#1}}}
\NewDocumentCommand\mykey{m}{\textcolor{brown3}{\mbox{\fakeverb{#1}}}}
\NewDocumentCommand\myval{m}{\textcolor{azure3}{\mbox{\fakeverb{#1}}}}
\NewDocumentCommand\myelem{m}{\textcolor{violet3}{\mbox{#1}}}

\begin{document}

{%
  \renewcommand{\arraystretch}{2}%
  \noindent\Large
  \begin{tabularx}{\linewidth}{|X|}
    \hline
    Title:   \ExamFillUlineText{\color{blue3}The randexam class for LaTeX}\\
    Author:  \ExamFillUlineText{Jianrui Lyu (tolvjr@163.com)}\\
    Version: \ExamFillUlineText{\myversion{} (\mydate)}\\
    Code:    \ExamFillUlineText{\url{https://github.com/lvjr/randexam}}\\
    \hline
  \end{tabularx}%
}

\tableofcontents

\section{Introduction}

Document class \mypkg{randexam} is an exam class for LaTeX.
With this class you could easily make an exam paper and its randomized variants.

The class mainly focuses on making math exam papers, but you could use it to make other exam papers.

The latest release of this package can be downloaded from here: \newline
\textcolor{blue}{\href{https://ctan.org/pkg/randexam}{\ttfamily https://ctan.org/pkg/randexam}}.

\section{Basic Structure}

\subsection{A randexam document}

The following is the basic structure of a \mypkg{randexam} document:
\begin{code}
\documentclass{randexam}
% document preamble
\begin{document}
% document body
\end{document}
\end{code}
In document preamble you could set some options for the exam.
In document body you write the contents of the exam.

\subsection{Document preamble}

In document preamble you normally set some class options with \mycmd{\SetExamOption} command.
For example, you could change the random seed with \myopt{seed} key. The seed is used only when
you add class option \myopt{random} (see Subsection \ref{opt:random}):
\begin{code}
\SetExamOption{
  seed = 19061116, % random seed
}
\end{code}

\subsection{Document body}

In document body you normally write an \mycmd{\examtitle},
multiple \mycmd{\exampart}, and an optional \mycmd{\examdata} commands:

\begin{code}
\examtitle{name=Math Final Exam,date=2018-06-28,version=A}
......
\exampart{Fill in the blanks.}[3 points for each.]
......
\exampart{Select one answer.}[3 points for each.]
......
\exampart{Work out math calculations.}[8 points for each.]
......
\examdata{Some data may be used in the exam}
......
\end{code}

\subsection{Exam title}

In calling \mycmd{\examtitle} command,
you need to provide some basic informations of the exam:

\begin{code}
\examtitle{name=Math Final Exam,date=2018-06-28,version=A}
\end{code}

If the \mykey{date} key is missing, it has the default value \myval{\today}.
When class option \myopt{random} is passed, the value of \mykey{version} key
will be modified from \myval{A} to \myval{B}.

\subsection{Exam parts}

The questions in an exam could be separated into several parts:

\begin{code}
\exampart{Fill in the blanks.}[3 points for each.]
......
\exampart{Select one answer.}[3 points for each.]
......
\exampart{Work out math calculations.}[8 points for each.]
......
\end{code}

\subsection{Exam data}

At the end of the exam, you could add some appendix data with \mycmd{\examdata} command:

\begin{code}
\examdata{Some data may be used in the exam}
......
\end{code}

You must put appendix data after \mycmd{\examdata} command,
or the exam variants will be incorrect.

\section{Types of questions}

\subsection{True-or-false questions}

\begin{code}
\exampart{True-or-false questions}[3 points for each.]

\begin{question}
The first true-or-false question. \tickout{T}
\end{question}

\begin{question}
The second true-or-false question. \tickout{F}
\end{question}
\end{code}

\begin{question}
The first true-or-false question. \tickout{T}
\end{question}

\begin{question}
The second true-or-false question. \tickout{F}
\end{question}

With \mycmd{\tickout{T}} and \mycmd{\tickout{F}}, you get \textcolor{blue}{\textsf{T}}
and \textcolor{blue}{\textsf{F}}; with \mycmd{\tickout{t}} and \mycmd{\tickout{f}},
you get \textcolor{blue}{$\checkmark$} and \textcolor{blue}{\large$\times$}.

You must put answers inside \mycmd{\tickout} command,
so as to make \mypkg{randexam} hide them in generating blank exam papers.

\subsection{Fill-in-the-blank questions}

\begin{code}
\exampart{Fill in the blanks.}[3 points for each.]

\begin{question}
The first fill-in-the-blank question \fillout{answer}.
\end{question}

\begin{question}
The second fill-in-the-blank question \fillout{answer}.
\end{question}
\end{code}

\begin{question}
The first fill-in-the-blank question \fillout{answer}.
\end{question}

\begin{question}
The second fill-in-the-blank question \fillout{answer}.
\end{question}

With \mycmd{\fillout} command, the underline will fill the whole line;
with \mycmd{\fillin} command, the underline will be minimal.

You must put answers inside \mycmd{\fillout} or \mycmd{\fillin} command,
so as to make \mypkg{randexam} hide them in generating blank exam papers.

\subsection{Multiple-choice questions}

\begin{code}
\exampart{Select one answer.}[3 points for each.]

\begin{question}
The first multiple-choice questions \pickout{A}.
\begin{abcd}
  \item First
  \item Second
  \item Third
  \item Fourth
\end{abcd}
\end{question}

\begin{question}
The second multiple-choice questions \pickout{C}.
\begin{abcd}
  \item First choice
  \item Second choice
  \item Third choice
  \item Fourth choice
\end{abcd}
\end{question}
\end{code}

\begin{question}
The first multiple-choice questions \pickout{A}.
\begin{abcd}
  \item First
  \item Second
  \item Third
  \item Fourth
\end{abcd}
\end{question}

\begin{question}
The second multiple-choice questions \pickout{C}.
\begin{abcd}
  \item First choice
  \item Second choice
  \item Third choice
  \item Fourth choice
\end{abcd}
\end{question}

With \mycmd{\pickout} command, the answer will be printed on the right edge of the line;
with \mycmd{\pickin} command, the answer will be printed on current position.

You must put answers inside \mycmd{\pickout} or \mycmd{\pickin} command,
so as to make \mypkg{randexam} hide them in generating blank exam papers.

The four choices of multiple-choice questions could be typeset with \myenv{abcd} environment.
And \myenv{abcd} environment will put them in one, two, or four rows
according to the lengths of the choices.

\subsection{Subjective questions}

For subjective questions, you could put answers inside \myenv{solution} environment.

\begin{code}
\exampart{Work out math calculations.}[8 points for each.]

\begin{question}
The first math calculation question.
\end{question}

\begin{solution}
Answer to the first question.
\end{solution}

\begin{question}
The second math calculation question.
\end{question}

\begin{solution}
Answer to the second question.
\end{solution}
\end{code}

\begin{question}
The first math calculation question.
\end{question}

\begin{solution}
Answer to the first question.
\end{solution}

\begin{question}
The second math calculation question.
\end{question}

\begin{solution}
Answer to the second question.
\end{solution}

\subsection{Other questions}

You can write other types of questions. For example:

\begin{code}
\exampart{Some question type}[4 points for each.]

\begin{question}
First question text. \answer{Answer text.}
\end{question}

\begin{question}
Second question text. \answer{Answer text.}
\end{question}
\end{code}

\begin{question}
First question text. \answer{Answer text.}
\end{question}

\begin{question}
Second question text. \answer{Answer text.}
\end{question}

You must put answer text inside \mycmd{\answer} command,
so as to make \mypkg{randexam} hide them in generating blank exam papers.

\section{Other components}

\subsection{Grade tables}

Normally you need a grade table after exam title.
You can get it by using \mycmd{\gradetable} command.

\begin{code}
\gradetable[total=6,strut=2em]
\end{code}

\vspace{-1.5em}\gradetable[total=6,strut=2em]

The meanings of keys in the \verb!\gradetable! command are:
\begin{description}
  \item[total] total number of parts in this exam.
  \item[strut] strut height of the score row; its default value is \verb!2.5em!.
\end{description}

\subsection{Answer tables}

Before true-or-false, fill-in-the-blank, or multiple-choice questions,
you may use \mycmd{\answertable} to generate a blank answer table:

\begin{code}
\answertable[total=6,column=3,strut=3em]
\end{code}

\answertable[total=6,column=3,strut=3em]

The meanings of keys in the \verb!\answertable! command are:
\begin{description}
  \item[total] total number of questions in this exam part.
  \item[column] number of questions in each row.
  \item[strut] strut height of the answer rows; its default value is \verb!1em!.
  \item[notice] notice text before the answer table.
\end{description}

\subsection{Vertical space}

You could leave some vertical space after a \myenv{question} or \myenv{solution} environment.
At this time \mypkg{randexam} class supports the following commands for adding vertical space:\par

\renewcommand{\arraystretch}{1.3}%
\begin{tabularx}{\linewidth}{l<{\qquad}X}
  \hline
  \texttt{\string\smallskip} & Add small vertical space\\
  \hline
  \texttt{\string\medskip}   & Add medium vertical space\\
  \hline
  \texttt{\string\bigskip}   & Add big vertical space\\
  \hline
  \texttt{\string\vfill}     & Fill vertical space available\\
  \hline
\end{tabularx}\par

Of course, you could use multiple commands in the above tables.

In the exam body, you could use \mycmd{\newpage} to make a page break,
but you should \underline{NOT} use other page breaking commands, such as \mycmd{\clearpage},
or the exam variants may be wrong.

\section{Writing questions}

\subsection{points key}

The \myenv{question} environment accepts a \mykey{points} key:

\begin{code}
\begin{question}[points=4]
This is a question.
\end{question}
\end{code}

\begin{question}[points=4]
This is a question.
\end{question}

\section{Writing solutions}

\subsection{Solution name}

If you would like to change the name of \myenv{solution} environment,
you could modify the translation of \mykey{solution-Solution} keyword
(see Subsection \ref{subsect:translation}).
The following example changes it from "Solution" to "Proof":

\begin{code}
\SetExamTranslation{solution-Solution=Proof}
\begin{solution}
  This is the proof.
\end{solution}
\end{code}

\begingroup
\SetExamTranslation{solution-Solution=Proof}
\begin{solution}
  This is the proof.
\end{solution}
\endgroup

\subsection{Points command}

Inside \myenv{solution} environment, you could use \mycmd{\points} to give points for each step.
For example:

\begin{code}
\begin{solution}
$1+1=2$ \points{4}
$2+2=4$ \points{8}
\end{solution}
\end{code}

\begin{solution}
$1+1=2$ \points{4}
$2+2=4$ \points{8}
\end{solution}

You can also use \mycmd{\points} command inside displayed formulas or \myenv{align*} environment.
And the point text will be printed at the right edge of the line.

\subsection{Alignment commands}

With class option \myopt{freealign}, \mypkg{randexam} loads \mypkg{freealign} package,
and \mypkg{freealign} package provides several commands for aligning math formulas in different lines.

Here is the first example:

\begin{code}
We have $(a+b)^2 \? = (a+b)(a+b)$ \\
                 \+$= a^2+2ab+b^2$ \points{2}
\end{code}

\hrule
We have $(a+b)^2 \? = (a+b)(a+b)$ \\
                 \+$= a^2+2ab+b^2$ \points{2}
\hrule\vskip0.5em

The \mycmd{\?} command \underline{inside} the first formula saves current horizontal position,
and the \mycmd{\+} command \underline{before} the second formula jumps to previously saved position.

Here is another example:

\begin{code}
We have \? $(a+b)^2 = (a+b)(a+b)$ \\
        \< $= a^2+2ab+b^2$ \points{2}
\end{code}

\hrule
We have \? $(a+b)^2 = (a+b)(a+b)$ \\
        \< $= a^2+2ab+b^2$ \points{2}
\hrule\vskip0.5em

The \mycmd{\?} command \underline{before} the first formula saves current horizontal position,
and the \mycmd{\<} command \underline{before} the second formula jumps to the left
of previously saved position by the width of $=$.

Because \mypkg{freealign} package uses \mypkg{zref} package to save positions,
you need two compilations to get correct results.

\section{Class options}

All options provided by \mypkg{randexam} class are listed in the following table:

\begin{tabularx}{\linewidth}{@{}lX@{}}
\toprule
  \myopt{noanswer}   & hide all answers in the exam paper \\
  \myopt{random}     & shuffle questions in each part \\
  \myopt{seed}       & the random seed used by \myopt{random} option \\
\midrule
  \myopt{plain}      & set page style \myval{plain} \\
  \myopt{a3paper}    & typeset a two-column paper of A3 size \\
  \myopt{a3input}    & input a paper of A4 size and change it to A3 size \\
\midrule
  \myopt{mathdesign} & use \mypkg{mathdesign} utopia font \\
  \myopt{freealign}  & load \mypkg{freealign} package \\
  \myopt{medmath}    & load \mypkg{medmath} package \\
  \myopt{moremath}   & define more math commands \\
  \myopt{math=many}  & $\Leftrightarrow$ \myopt{mathdesign,freealign} \\
  \myopt{math=most}  & $\Leftrightarrow$ \myopt{mathdesign,freealign,medmath} \\
  \myopt{math=all}   & $\Leftrightarrow$ \myopt{mathdesign,freealign,medmath,moremath} \\
\midrule
  \myopt{language}   & set language and use corresponding translations \\
 %\myopt{chinese}    & select Chinese language and load \mypkg{ctex} package \\
\bottomrule
\end{tabularx}

Some of the options could also be modified with \mycmd{\SetExamOption}:
\myopt{noanswer}, \myopt{random}, and \myopt{seed}.

\subsection{Blank exam papers}

Assume \myfile{exam-a-answer.tex} is an exam paper with answers.
You can easily get a blank exam paper with answers removed,
by creating an \myfile{exam-a-blank.tex} file with the following lines:

\begin{code}
\PassOptionsToClass{noanswer}{randexam}
\input{exam-a-answer}
\end{code}

That is to say, when adding \myopt{noanswer} option to \mypkg{randexam} class,
The answers will be hidden in the compiled exam paper.

\subsection{Randomized variants}\label{opt:random}

Assume \myfile{exam-a-answer.tex} is an exam paper.
You could get a randomized variant with all questions in the same part shuffled,
by creating an \myfile{exam-b-answer.tex} file with the following lines:

\begin{code}
\PassOptionsToClass{random}{randexam}
\input{exam-a-answer}
\end{code}

That is to say, when adding \myopt{random} option to \mypkg{randexam} class,
The questions in the same part will be shuffled in the compiled exam paper.
Furthermore, four choices in an \myenv{abcd} environment will be shuffled too.

\subsection{Two column exam papers}

Assume \myfile{exam-a-blank.tex} is the TeX file of an exam paper of A4 size.
You could get an exam paper of A3 size,
by creating a new TeX file with the following lines:

\begin{code}
\PassOptionsToClass{a3paper}{randexam}
\input{exam-a-blank}
\end{code}

That is to say, when adding \myopt{a3paper} option to \mypkg{randexam} class,
The result paper will be a two column document in A3 size.

Assume \myfile{exam-a-blank.pdf} is the PDF file of an exam paper of A4 size.
You could get an exam paper of A3 size,
by creating a new TeX file with the following lines:
\begin{code}

\documentclass[a3input]{randexam}
\begin{document}
\includepdf[pages=-,nup=2x1]{exam-a-blank}
\end{document}
\end{code}

That is to say, you can make an exam of A3 size from an exam of A4 size,
even if you have only the PDF file.

\section{Customizations}

\subsection{Translations of keywords}\label{subsect:translation}

With \mycmd{\DeclareExamTranslation} you can define the translaitons of the keywords
in a \mypkg{randexam} paper.

\begin{code}
\DeclareExamTranslation{english}{
   answertable-Answer   = Answer
  ,answertable-Number   = Number
  ,examdata-Appendix    = Appendix
  ,exampart-Part        = Part
  ,examtitle-Name       = Name
  ,examtitle-Solutions  = Solutions
  ,gradetable-Evaluator = Evaluator
  ,gradetable-Part      = Part
  ,gradetable-Score     = Score
  ,gradetable-Total     = Total
  ,headfoot-Name        = Name
  ,headfoot-of          = of
  ,headfoot-Page        = Page
  ,headfoot-Solutions   = Solutions
  ,headfoot-Version     = Version
  ,points-point         = point
  ,points-points        = points
  ,question-Question    = Question
  ,solution-Solution    = Solution
}
\end{code}

At this time only English and Chinese keywords are defined.
You could translate them for another language and enable them
with \mycmd{\SelectExamTranslation} command:

\begin{code}
\DeclareExamTranslation{somelang}{
   question-Question    = Questioooooon
  ,solution-Solution    = Soooooolution
}
\SelectExamTranslation{somelang}
\end{code}
\DeclareExamTranslation{somelang}{
   question-Question    = Questioooooon
  ,solution-Solution    = Soooooolution
}
\SelectExamTranslation{somelang}

After this, you could load current translation of some keywords with \mycmd{\UseExamTranslation} command:

\begin{code}
\UseExamTranslation{question-Question}
\UseExamTranslation{solution-Solution}
\end{code}
\hrule
\UseExamTranslation{question-Question}
\UseExamTranslation{solution-Solution}
\vspace{0.5em}
\hrule
\vspace{0.5em}

\SelectExamTranslation{english}

This command is useful in defining new templates for the exam (see Subsection \ref{subsect:template}).

\subsection{Checking current language}

There are commands \mycmd{\IfExamLanguageEqT},
\mycmd{\IfExamLanguageEqF}, and \mycmd{\IfExamLanguageEqTF},
with which you can execute code based on current language.

\subsection{Checking boolean flags}

There are several commands for creating, setting, or checking boolean flags:

\begin{tabularx}{\linewidth}{@{}lX@{}}
\toprule
  \mycmd{\NewExamBool}      & create a new boolean flag \\
  \mycmd{\SetExamBoolTrue}  & set the boolean flag to true \\
  \mycmd{\SetExamBoolFalse} & set the boolean flag to false \\
  \mycmd{\IfExamBoolT}      & run code if the boolean flag is true \\
  \mycmd{\IfExamBoolF}      & run code if the boolean flag is false \\
  \mycmd{\IfExamBoolTF}     & run true-state code or false-state code \\
\bottomrule
\end{tabularx}

\subsection{Saving and reading key values}

With \mycmd{\SetExamValue} and \mycmd{\UseExamValue} you could save and read
the value of a key, respectively.

\begin{code}
\SetExamValue{somemodule}{somekey=SomeValue}
\UseExamValue{somemodule}{somekey}
\end{code}
\hrule
\SetExamValue{somemodule}{somekey=SomeValue}
\UseExamValue{somemodule}{somekey}
\vspace{0.5em}
\hrule
\vspace{0.5em}

The class also provides commands for conditional typesetting.

\begin{tabularx}{\linewidth}{@{}XXX@{}}
\toprule
\mycmd{\IfExamValueExistT} & \mycmd{\IfExamValueExistF} & \mycmd{\IfExamValueExistTF} \\
\mycmd{\IfExamValueEmptyT} & \mycmd{\IfExamValueEmptyF} & \mycmd{\IfExamValueEmptyTF} \\
\bottomrule
\end{tabularx}

\begin{code}
\IfExamValueExistTF{somemodule}{somekey}{True}{False}
\end{code}
\hrule
\IfExamValueExistTF{somemodule}{somekey}{True}{False}
\vspace{0.5em}
\hrule
\vspace{0.5em}

Furthermore, you may change typeset command of some counter with \mycmd{\SetExamValue}
and the counter is typeset with \mycmd{\TheExamCounter} command when needed.

\setcounter{exampart}{4}
\begin{code}
\SetExamValue{exampart}{number=\Roman}
\SetExamValue{question}{number=\arabic}
Part \TheExamCounter{exampart},
Question \TheExamCounter{question}
\end{code}
\hrule
\SetExamValue{exampart}{number=\Roman}
\SetExamValue{question}{number=\arabic}
Part \TheExamCounter{exampart},
Question \TheExamCounter{question}
\vspace{0.5em}
\hrule
\vspace{0.5em}

These commands are useful in defining new templates
for the exam (see Subsection \ref{subsect:template}).

\subsection{Templates of elements}\label{subsect:template}

With \mycmd{\DeclareExamTemplate} you could define a new template for some exam element,
which could be set as default template with \mycmd{\SelectExamTemplate}.
And with \mycmd{\UseExamTemplate} you could use the default template of the element.

To customize \myelem{examtitle} element for your school,
you can write the following code in document preamble:
\begin{code}
\DeclareExamTemplate{examtitle}{myschool}{%
  \fbox{%
    \UseExamValue{examtitle}{name}\quad%
    \UseExamValue{examtitle}{date}%
  }%
}%
\SelectExamTemplate{examtitle}{myschool}
\end{code}
\DeclareExamTemplate{examtitle}{myschool}{%
  \fbox{%
    \UseExamValue{examtitle}{name}\quad%
    \UseExamValue{examtitle}{date}%
  }%
}%
\SelectExamTemplate{examtitle}{myschool}

Then the \mycmd{\examtitle} command in document body will produce different result:
\begin{code}
\examtitle{name=Final Exam in My School,date=\today}
\end{code}
\vspace{-1em}
\examtitle{name=Final Exam in My School,date=\today}

Normally \mycmd{\examtitle} will call \mycmd{\UseExamTemplate{examtitle}{default}}.

All elements that could be customized with templates in an exam paper
are listed in the following table:

\begingroup\renewcommand\arraystretch{1.5}\noindent
\begin{tabularx}{\linewidth}{ll}
\hline
  \myelem{examtitle}     & for customizing \mycmd{\examtitle} command \\
\hline
  \myelem{exampart}      & for customizing \mycmd{\exampart} command \\
\hline
  \myelem{examdata}      & for customizing \mycmd{\examdata} command \\
\hline
  \myelem{gradetable}    & for customizing \mycmd{\gradetable} command \\
\hline
  \myelem{answertable}   & for customizing \mycmd{\answertable} command \\
\hline
  \myelem{questionbegin} & for customizing \myenv{question} environment \\
\hline
  \myelem{questionend}   & for customizing \myenv{question} environment \\
\hline
  \myelem{solutionbegin} & for customizing \myenv{solution} environment \\
\hline
  \myelem{solutionend}   & for customizing \myenv{solution} environment \\
\hline
\end{tabularx}\par
\endgroup

\subsection{Filling space with contents}

In defining exam templates, we may need the following filling commands.

\begin{tabularx}{\linewidth}{@{}lX@{}}
\toprule
  \mycmd{\ExamFillCdot}         & fill space with centered dots \\
  \mycmd{\ExamFillUline}        & fill space with an underline \\
  \mycmd{\ExamFillUlineText}    & fill space with underlined text \\
  \mycmd{\ExamFillUlinePhantom} & fill space with underlined phantom text \\
\bottomrule
\end{tabularx}

\begin{code}
Hello\ExamFillCdot World\par
Hello\ExamFillUline World\par
Hello\ExamFillUlineText{Text}World\par
Hello\ExamFillUlinePhantom{\Huge Text}World\par
\end{code}

Hello\ExamFillCdot World\par
Hello\ExamFillUline World\par
Hello\ExamFillUlineText{Text}World\par
Hello\ExamFillUlinePhantom{\Huge Text}World\par

\subsection{Headers and Footers}

To customize headers and footers of the exam paper,
we could modify the following \myval{fancy} templates.

\begin{code}
\DeclareExamTemplate{headleft}{fancy}{
  \UseExamValue{examtitle}{name}
}
\DeclareExamTemplate{headcenter}{fancy}{}
\DeclareExamTemplate{headright}{fancy}{
  \IfExamBoolTF{answer}{
    \UseExamTranslation{headfoot-Solutions}
  }{
    \UseExamTranslation{headfoot-Name}:\hspace{12em}
  }
}
\DeclareExamTemplate{footleft}{fancy}{
  \UseExamValue{examtitle}{date}
}
\DeclareExamTemplate{footcenter}{fancy}{
  \UseExamTranslation{headfoot-Page} \thepage\space
  \UseExamTranslation{headfoot-of} \zpageref{LastPage}
}
\DeclareExamTemplate{footright}{fancy}{
  \UseExamTranslation{headfoot-Version}
  \UseExamValue{examtitle}{version}
}
\end{code}

Actually, \mypkg{randexam} class uses \mypkg{fancyhdr} package
to customize headers and footers.

\subsection{Themes of exam papers}

With \mycmd{\DeclareExamTheme} command you can collect some templates into a theme,
which could be activated later with \mycmd{\SelectExamTheme} command.

\begin{code}
\DeclareExamTheme{mytheme}{
  \SelectExamTemplate{examtitle}{mytheme}
  \SelectExamTemplate{exampart}{mytheme}
  \SelectExamTemplate{examdata}{mytheme}
}
......
\SelectExamTheme{mytheme}
\end{code}

\end{document}
