# Not Just For Professors

First of all, this is not a LaTeX tutorial. I will not teach you LaTeX. There are far more qualified people who have done an excellent job on the matter. If you want to learn LaTeX, More Math Into LaTeX 4th Edition. It's fantastic. What I'm doing here is merely documenting some tricks to use LaTeX code to generate a math test. LaTeX, if you aren't aware, was designed primarily for university and research types to publish journal articles at a time long before word processor apps could properly display math symbols. It is a markup language akin to HTML but for documents. Very very pretty documents. If you know basic HTML and/or have taken a computer science course, it's just a matter of learning the syntax.

Previously I used Word 2008 and MathType to generate tests. But there are some hair-tearing frustrations that result from this, because Word has a very funky alignment grid for pictures and at random decides to align MathType formulas wherever it pleases. I also used Word objects to make any figures with so-so results.

I use TeXShop (part of the MacTeX package) to write the mark up and PDFPen to insert graphics. I make graphics in Fireworks CS5. LaTeX does support coding graphics but I've gotten better rendering results by leaving an appropriate blank in my .tex file and adding the graphic with PDFPen later. TeXShop outputs to PDF by default. PDFPen has a grid overlay you can enable and avoids all the headaches involved with trying to align something in Word. At the end of the article I have posted the Word version and LaTeX generated version of the same test so you can compare the results.

### Templates and Preamble

The fastest way to get a new document started is to have a nice template. LaTeX files require a decent preamble, and you don't want to type it every time. This is my template. Biggest thing here, after you make your template and are satisfied, close it in TeXShop, set the file aside from your primary work folder and LOCK it. Clicking "Typeset" in TeXShop saves your markup file and if the file isn't locked you WILL overwrite your template by accident.

%template for test creation

\documentclass[11pt]{amsart}

\usepackage{fullpage}

\usepackage[tmargin = 0.5in, bmargin = 1in, hmargin = 1in]{geometry}     %1-inch margins

\geometry{letterpaper}

\usepackage{graphicx}

\usepackage{amssymb}

\usepackage{epstopdf}

\pagestyle{empty}                       %no page numbers

\thispagestyle{empty}                   %removes first page number

\setlength{\parindent}{0in}               %no paragraph indents

\raggedright                               %left justified text

\DeclareGraphicsRule{.tif}{png}{.png}{convert #1 dirname #1/basename #1 .tif.png}

\begin{document}

Mr. Claydon\hspace{2.8in} Name:\ \makebox[1.366in]{\hrulefill} Date:\ \makebox[0.5in]{\hrulefill}\\

Pre\,-\,Calculus \hfill Period:\ \makebox[0.5in]{\hrulefill}

\vspace{6pt}

\begin{center}

\textbf{test title}

\end{center}

\vspace{12pt}

%uncomment for 2nd page

%\newpage

%Mr. Claydon\hfill \textbf{Test 5.3\,-\,5.4}\\

%Pre\,-\,Calculus

%\vspace{12pt}

%for bonuses

\vfill Bonus:

\end{document}

I commented the nice bits. The biggest things to keep you from making journal articles are suppressing page numbers and left justifying the text. Note my changes to the geometry package, by default LaTeX uses very odd margins. Odd margins for a test, anyway. There are no headers and footers really, so I make the top margin small and use the \vfill to shove my bonus question to the bottom regardless of how much of the page is used.

All of the makebox and hrulefill stuff generates lines they can write their name on. Took me a little bit of thinking to figure this out.

### Floating Alignment

The most important command you need. LaTeX is intended as sort of a one formula per line system, typical of journal articles. This alignment code will let you create a bank of problems all neatly ordered under one another. Similar to setting tab points in Word. A typical use case:

The code that makes it:

\begin{flalign*}

1.\ &\sum_{k=1}^{10}3(0.6)^{k-1} & 2.\ & \sum_{j=0}^{7}0.4\left(\frac{1}{5}\right)^{j} & 3.\ & \sum_{i=1}^{24}50(1.006)^{i-1}\\[24pt]

4.\ &\sum_{k=1}^{\infty}6\left(\frac{2}{3}\right)^{k-1} & 5.\ &\sum_{n=0}^{\infty}8(0.54)^{n} & 6.\ &\sum_{g=0}^{\infty}0.57\left(\frac{7}{2}\right)^{g}

\end{flalign*}

The flalign command tells LaTeX to use the full width of the page to align whatever you give it using the &s as tab points. The * is the key, it suppresses equation numbers. The [24pt] defines the vertical space between one line of equations and the next.

### Formula Boxes

In Pre-Cal there are many times where some formulas will help. Previously I would draw a text box and dump some MathType into it.

The code that makes it:

\begin{center}

\fbox{\parbox[l][1.3in]{1in}{Hinty Hints:\\%

\begin{align*}

& \frac{\sin A}{a}=\frac{\sin B}{b}=\frac{\sin C}{c}    &    a^{2}&=b^{2}+c^{2}%

-2bc\cos A &&\\[6pt]

&&    \cos A&=\frac{b^{2}+c^{2}-a^{2}}{2bc} &&

\end{align*}}}

\end{center}

I used a standard align command here because I didn't want to thrust what little I had to the far ends. The fbox makes the border, the parbox defines what goes inside. Not necessary if you just want to frame one equation or a bit of text, but necessary for a table or big set of formulas. The []'d portion defines width, the {} height.

### Text and Formula Boxes

It is possible for boxes to share space with other items.

The code that makes it:

\parbox{4in}{18.\ A baseball leaves the hand of the first baseman at an angle of $\theta$ with the horizontal and with an initial velocity of $v_{0}=80$ feet per second. The ball is caught by the second baseman 100 feet away. The range $r$ of a projectile is given by $r=\frac{1}{32}v_{0}^{2}\sin 2\theta$\dots speaking of baseball, how bummed are you that the faculty/senior softball game was cancelled?}\hfill\fbox{\parbox[c][1.5in]{2.1in}{\begin{center}$\tan\left(a+b\right)=\dfrac{\tan a + \tan b}{1 - \tan a\tan b}$\vspace{30pt}\\$\tan\left(a-b\right)=\dfrac{\tan a - \tan b}{1 + \tan a\tan b}$\\\end{center} }}

### Test Template

Finally, here is ny test template for my standards based grading system.

\documentclass[11pt]{amsart}
\usepackage{fullpage}
\usepackage[tmargin = 0.5in, bmargin = 1in, hmargin = 1in]{geometry}     %1-inch margins
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\pagestyle{empty}   %no page numbers
\thispagestyle{empty}   %removes first page number
\setlength{\parindent}{0in}   %no paragraph indents
\raggedright   %left justified text
\DeclareGraphicsRule{.tif}{png}{.png}{convert #1 dirname #1/basename #1 .tif.png}
\begin{document}
Mr. Claydon\hspace{2.8in} Name:\ \makebox[1.366in]{\hrulefill} Date:\ \makebox[0.5in]{\hrulefill}\\
Algebra II \hfill Period:\ \makebox[0.5in]{\hrulefill}
\vspace{6pt}
\begin{center}
\textbf{test title}
\end{center}
\vspace{12pt}
1.\ \emph{Topic Title} \hfill \makebox[0.3in]{\hrulefill} /4 pts.\\[6pt]
Directions.\\[6pt]
\begin{flalign*}
\end{flalign*}\\[1in]
\dotfill\\[6pt]
2.\ \emph{Topic Title} \hfill \makebox[0.3in]{\hrulefill} /4 pts.\\[6pt]
Directions.\\[6pt]
\begin{flalign*}
\end{flalign*}
%uncomment for 2nd page
\newpage
Mr. Claydon\hfill \textbf{Test No.}\\
Algebra II\\
\vspace{12pt}
\emph{Basics}\hfill \makebox[0.3in]{\hrulefill} /4 pts.\\[6pt]
Directions.\\[6pt]
\begin{flalign*}