Vim, LaTeX and High School

06 Oct 2012

This September, after a summer full of programming, I was forced back into my junior year in high school. Back to writing English essays, lab reports, and projects. Luckily, sometime over the summer I discovered LaTeX. LaTeX has many advantages over a proprietary WYSIWYG word proccesor like Microsoft Word or Apple’s Pages. Its free, it’s portable, and it’s friendly with mathematical and scientific notation out of the box. However, It also has its share of disadvantages. One of these disadvantages is the steep learning curve. Unlike the WYSIWYG editors, it’s not straightforward to set up or use. This is why I am writing this blog post, to share my experiences and help bootstrap someone eager to get started with LaTeX.

The Setup

Installing and setting up LaTeX on your machine varies, depending on what operating system you are on. The LaTeX project website lists some good TeX distributions available for download. I own a MacBook running OS X, so I have downloaded and installed MacTeX. It is a big download (>1GB), but it is comprehensive, including everything you need to get started.

To build TeX files into PDFs, I have found Rubber to be the easiest and most comprehensive solution out there. It abstracts away all the tasks involved with building a TeX document, and works on both Linux and OS X without problem. It is available for download and install in many package managers, including Homebrew on OS X.

If you use Vim, I highly recommend the TeX-PDF plugin. As the name implies, the plugin’s sole purpose is to build TeX into finished PDFs, using whatever is available. It will use Rubber if it finds it on the system. The plugin is well suited for high school projects, because building to PDFs is probably the only thing you need to do. Using Vundle, installation is as simple as adding Bundle "TeX-PDF” to your .vimrc file.

Getting Started

There are many resources available to those starting out with LaTeX. I have chosen to learn as I go, and figure out how to do something when I need to do it. However, I have learned some tips and tricks that would be particulary useful for fellow high school students.

Science

In writing lab reports for science classes, I have found the packages mhchem and siunitx to be very useful. Both of these are included in the TeX Live and MacTeX distributions. The first package, mhchem, makes it very easy to write out chemical formulae. It is extremely comprehensive, and supports all the notation I have needed for AP Chemistry thus far. To write the formula for dichromate, it simplifies

into

to draw

The other package, siunitx, allows you to typeset physical quantities with ease. For example, you can express the specific heat capacity of water with

to draw

siunitx supports (almost) every SI unit under the sun.

English

Writing English essays in LaTeX is very easy to do, thanks to the mla-paper package. It takes care of the MLA header in one line, which is very useful.

and the code:

Plotting

In all of my science classes, I have had to plot points on a graph, in one form or another. Yes, there is a package for that. Based on the graphics package pgf, pgfplots can be used to create high quality plots of all kinds. Here is a recent example of a project I did in AP Calculus, graphing a logistic function:

This example has four plots overlaid on top of one another. A scatter plot, the logistic regression, and its first and second derivatives. This example also includes labeled nodes, and a legend. pgfplots, like many of the other packages, is extremely comprehensive and extensible. Here is the code:

Conclusion

Deciding to switch to using only LaTeX for my schoolwork this year was a fantastic decision. Although I had to learn as I went, often under time constraints, it has certainly paid off. I can now edit my schoolwork with Vim. Mathematical and scientific notation is easy to write, and not a hassle anymore. I don’t have to rely on a proprietary word processor. I plan on taking this skill with me when I eventually head off to college.

Discuss on Hacker News here.