LaTeX for the Classroom, Episode 1

I've used LaTeX quite a lot in educational settings, in K-12 and beyond, from sixth grade geography quizzes to graduate level remote sensing lab guides to conference presentations. It's insanely flexible, and the community is phenomenal. I've yet to find anything that even approaches the quality of tools available for reference management and citation formatting in LaTeX, and the universe of user-contributed packages is vast, diverse, generally reliable, and well-documented. And it's all the better that I can keep my source files, because they're plain text, in a revision control system like git and track changes over time or in collaborations.

Below, I provide some notes for generating mid-term grade reports in LaTeX from tab-delimited data files. I know most instructors in higher ed use some sort of web-based "learning management system" like BlackBoard or Canvas, but sometimes you just want to hand a student a piece of paper, or, at least, I do. The use case here is a set of personalized grade reports, the kind that you might want to hand out after the mid-term examination.

The code here assumes that you have a tab-delimited file featuring columns for name, midterm, and paper1. The LaTeX document will be constructed in part by iterating over the rows in that file and typesetting one page for each student in the roster featuring their grades for these assignments as well as the percentage of the possible points they've scored. It could look something like this:

name         id     uname   paper1  midterm
Grace Jones  66666  gjones  2.75    8.5
David Bowie  77777  dbowie  4.75    8.5
Patti Smith  88888  psmith  2.75    8.5


The code sets up a generic document with pages formatted for A6 paper, meaning that we'll be able to print four of them to each sheet of standard A4 copier paper. You can see that we first load an assortment of packages, some of which are quite optional. The meat here is the datatool package, which will parse our data file and provide macros to iterate over each row, in this case representing students and their grades.

\documentclass[english]{article}

\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[a6paper, margin=7.5mm, bindingoffset=0mm]{geometry}
\usepackage{anyfontsize}
\usepackage{rotating}
\usepackage{helvet}
\renewcommand*\familydefault{\sfdefault}

\usepackage{datatool}

\DTLsettabseparator

\usepackage{fp}

\begin{document}

\DTLforeach{roster}{%
\name=name,\paperone=paper1,\midterm=midterm}{

\noindent{\fontsize{24}{29}\selectfont \bf \name}\\
\vspace{4pt}\\
Below are your scores on graded assignments as they appear in my records as of {\it today}.
\vspace{3pt}\\
{\noindent}If you have questions, email me or drop by my office hours.
\vspace{12pt}\\

\noindent{\fontsize{16}{19}\selectfont \bf Paper One\hfill\paperone}\\
\vspace{4pt}\\
\noindent{\fontsize{16}{19}\selectfont \bf Midterm Exam\hfill\midterm}\\
\vspace{8pt}\\\FPeval{\curpoints}{clip(paperone+midterm)}\FPeval{\curpercent}{round(curpoints/17*100, 2)}
\noindent{\fontsize{16}{19}\selectfont \bf \it Total\hfill\curpoints/17}\\
\vspace{3pt}\\
\null\hfill{\fontsize{16}{19}\selectfont \bf \it \curpercent\%}\\

\newpage
}

\end{document}


You'll notice that I'm using the fp package for doing arithmetic and storing the results in macros, e.g. \paperone, so LaTeX not only does my typesetting, but also does the small calculations I need to make these reports.

The output looks something like the image below.

The A6 sheets can then be printed four to a sheet. Simply change the printer settings when printing from your PDF reader to print 2x2, then cut each printed page into four.

Once this is set up, it's pretty convenient to generate reports throughout the semester, and I think they look quite nice. LaTeX, once again, has all the tools for automating tedious, repetitive tasks, and saves time for more interesting and fruitful work, like reading that paper or book that's been sitting on your desk for far too long.