LaTeX is meant exactly for stuff like this. LaTeX is a programming language of sorts, designed with the explicit purpose of typesetting documents... like, say, an essay template. It spits out nice, vectorized PDFs across Windows, OSX, and Linux, and it's also possible to define your own custom formats and commands.
There's a wealth of documentation available online, which enables even complete beginners to get up and running pretty quickly. Services like ShareLaTeX allow collaboration and versioning, as well as including features that users of word processors take for granted (e.g. a spell checker).
And, just as a fun example, the output from a bit of LaTeX "code". The snippet $\frac{1}{z} = \frac{z^*}{x^2 + y^2}$
yields this:

Which you might recognize as the equation in the example exam page. Oh, and when rendered as a PDF, even the math stuff comes out as copy-able text (though, depending on where you're copying to, results may vary).
There's also a TeX/LaTeX StackExchange site for your more advanced questions. Like, say, how to typeset an exam paper. (Thanks @Gallifreyan!)