Introduction
LaTeX has long been my main typesetting environment. This post has some handy dandy codes that I daily use.
Exam Template
Below is the template I developed over time based on the Exam
class. It is quite flexible and functional.
\input{_preamble}
file codes:
\runningheader{\class}{Lab \day\ Worksheet}{Page \thepage\ of \numpages}
\runningheadrule
%\framedsolutions
\unframedsolutions
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{multicol} % Multi column environment
\usepackage{siunitx} % Format scientific units
\usepackage{chemformula} % Format Chemical Formulae
\usepackage{adjustbox}
\usepackage{tabularx}
%% MoveQuestionNextPage
\newcommand{\MoveQuestionNextPage}{
\ifprintanswers \else
\clearpage
\fi
}%
%% Color settings
\definecolor{blue-violet}{rgb}{0.54, 0.17, 0.89}
\SolutionEmphasis{\color{blue-violet}}
\CorrectChoiceEmphasis{\color{blue-violet}\bfseries}
\input{_instructions}
file codes:
\ifprintanswers
\firstpageheader{\class}{Lab \day\ Worksheet}{\examdate}
\firstpageheadrule
\begin{center}
{\color{blue-violet}{\large{\textbf{KEY}}}}
\end{center}
\else
\noindent
\begin{tabular*}{\textwidth}{@{}l @{\extracolsep{\fill}} r @{\extracolsep{5pt}} l@{}}
\textbf{\class\ - Worksheet} & \textbf{Name:} & \fillin \fillin \\
\textbf{Lab \day. \topic} &\textbf{Date:} & \fillin \fillin \\
\textbf{Section: \fillin} &\textbf{TA:} & \fillin \fillin \\
\end{tabular*}\\
\rule[1ex]{\textwidth}{2pt}
%This worksheet contains \numpages\ pages and \numquestions\ questions. Please add all the names of "contributing group members."
%
%\begin{center}
%
%Grade Table (for teacher use only)\\
%\addpoints
%\resizebox{\textwidth}{!}{
%\gradetable[h][questions]
%}
%\end{center}
%
%\noindent
%\rule[1ex]{\textwidth}{2pt}
\fi
Add a Question with Solution Box
\question
\begin{solutionorbox}[\fill]
\end{solutionorbox}
Add a Multiple Choice Question
One line:
\begin{oneparchoices}
\choice
\end{oneparchoices}
Multiple lines:
\begin{choices}
\choice
\end{choices}
Add a Multipart Question
\question
\begin{parts}
\part
\begin{solutionorbox}[\fill]
\end{solutionorbox}
\part
\begin{solutionorbox}[\fill]
\end{solutionorbox}
\end{parts}
Add a Two-Column Question (Layout)
\begin{minipage}{0.6\textwidth}
\question
\begin{oneparchoices}
\choice
\CorrectChoice
\end{oneparchoices}
\begin{solution}
\end{solution}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\fbox{\includegraphics[width=.94\textwidth]{}}
\end{minipage}
Add Bonus Questions/Parts
\bonusquestion[5]
\bonuspart[5]
Move Question to Next Page
Move question/part to the next page to satisfy space requirements. \MoveQuestionNextPage
is omitted while Exam Key
is generated because key does not need any answer space for data entry.
\MoveQuestionNextPage
Command in preamble:
\newcommand{\MoveQuestionNextPage}{
\ifprintanswers \else
\clearpage
\fi
}
Checkboxes
\begin{checkboxes}
\choice
\end{checkboxes}
Changing checkbox style locally:
{
\checkboxchar{$\Box$}
\begin{checkboxes}
\choice
\end{checkboxes}
}
Changing choice items style locally:
{
\renewcommand*\thechoice{\arabic{choice}}
\renewcommand*\choicelabel{\thechoice)}
\question[2]
\begin{multicols}{2}
\begin{choices}
\choice
\end{choices}
\end{multicols}
}
Make Formatted Textareas
Empty box:
\makeemptybox{1.5in}
\makeemptybox{\fill}
Fill with lines:
\fillwithlines{\fill}
Fill with dotted lines:
\fillwithdottedlines{8em}