Image for post
Image for post
Artwork generated using Art Breeder

Quick Guide to LaTeX for Homework

Skip the opening if you’re in a hurry to start writing your homework.

During my first year at University, I was surprised to learn that you could study more than one degree. I planned only to study CS, but after some encouragement, decided to also pursue mathematics. Thanks to AP credits, I triumphantly jumped straight into Multivariable Calculus and unsurprisingly failed! Given two lazy years prior, and I had become terrible at everything by hand. But as the saying goes, if you fail, try again. I searched how to become a mathematician, and a recurring theme was this strange word called LaTeX. I never heard about it before, but if so many math posts mentioned it, it must be important, so I learned as much as possible. The following semester with accompanied by neatly typed proofs, but it appeared that my inability to do calculations by hand had become chronic and failed Multivariable Calculus yet again. With my GPA in shambles, my brief dreams of studying mathematics came to an end. It was nice to try, but at least I know how to use LaTeX now for my CS homework!

LaTeX is a lovely piece of software for creating documents. I’ve seen most people use LaTeX to type up their resumes, homework, research papers, and even presentations (though I would use a different tool for that). Whatever it is, if it has any sorts of math in it, you’ll probably enjoy using LaTeX to get the job done.

When I first started, the hardest thing for me was figuring out how to get going. Many people use Overleaf, an online LaTeX editor that you can start using for free and pay a monthly fee for more features, but I prefer something running on my machine. We’ll go step by step, getting everything working on Windows. The same steps should work on Mac and Linux, but I can’t say for sure until I try it out myself.

Installing MikTeX

There are many other ways of getting LaTeX installed, but I like the system MikTeX has that downloads packages as you need them (rather than my old approach of just downloading texlive-full).

Head over to https://miktex.org/download and run the installer. For the sake of brevity, we’ll assume you always verify checksum, read the entire license agreements, and all that jazz before installing any piece of new software.

Image for post
Image for post

Once the installer finishes hit close and done! On windows, if you ever want to find it again, head to your file C:\Users\yournamehere\AppData\Local\Programs
to find the MikTex Console.The default editor that comes with MikTex is Texworks, and you can start using that, but I want something more colorful.

Image for post
Image for post
A very intriguing TeXworks

Preparing VS Code for LaTeX

Instead of TeXWorks, let’s use VS Code. Open up VS Code (or install it if you don’t already) and download the LaTeX Workshop extension. You’ll usually find it by searching for Latex in the extension marketplace. It’ll provide syntax highlighting and a few other neat features like being able to preview your generated PDFs while in VS code.

Image for post
Image for post

Create a new folder, and make a file in it called hello.tex

and paste into it the following:
\documentclass[12pt]{article}
\begin{document}
Hello world
\end{document}

Open up your terminal, and type pdflatex hello.tex If whenever MikTex asks you to install packages, just press okay and download them since it’s usually necessary. If you look in your folder, there should be a hello.pdfthat has been compiled. Open it and observe in awe, our first LaTeX PDF.

Image for post
Image for post
Such beauty and elegance

Everything should technically work now, but we want the LaTeX workbench. If you try running some of the commands from the sidebar button labeled TeX, it might give you an error.

Image for post
Image for post
Maybe not on MacOS, I’ve heard Perl comes preinstalled

Unless you’re a Perl developer, you’ll need to install Perl. Go to https://www.perl.org/get.html and download ActiveState Perl.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Once it finishes downloading, close and reopen VS Code. Go back to the TEX button on your sidebar, and now press Build Latex Project

Install any packages if it asks you again and done, everything should work fine! Press View LaTeX PDF

and you’ll get to see your project on the side just nice. Everything is ready for your LaTeX journey!

My last two cents to improving your VS Code workflow is getting a nice theme, my favorite is Dracula along with using a font that supports ligatures, my favorite FiraCode.

LaTeX basics

With everything ready, time to focus on actually writing something. But we shouldn’t reinvent the wheel, and usually, a LaTeX template already exists out there for most needs. We’ll consider an example if you’re writing homework. For some classes, professors offer extra credit points to those who type up their homework to spare their graders of most suffering. So we search online “latex proof template,” and the first result already looks very appealing.

Image for post
Image for post

When you visit the site, you could get started right away using the template with their editor, but we want to work in our environment. Press View Source and copy-paste the template text into a new file, say hw.tex

Image for post
Image for post

Every LaTeX command starts with a backslash. The beginning part is the Preamble. Usually, you don’t want to edit much here if you’re using a template, but know you can use it to change document like the font size or including other packages you might need. In the case of writing math proof homework, we’ll leave the template as is. The meat and potatoes is everything inside the \begin{document} and \end{document}tags.

First three bits are important to set your class name, your name and date. Change it to whatever you want. Everything else is whatever you want it to be.

If you weren’t using this template, you would normally do include something like so instead in your preamble

\author{Your name}
\date{\today}
\title{A title about Potatoes?}

And then do \maketitleright after your \begin{document}.

Delete everything from inside here from the template and use it for whatever you want but in my personal use, I found it very nice to keep using the \begin{problem}\end{problem}\begin{proof}\end{proof} pattern for all my homework.

All the commands so far have been in text-mode but what about the cool math symbols we wanted? To get those, you need to get into math mode by using dollar signs. Whenever you want to write some inline math equation, you’ll type $mathstuffinhere$and type math stuff inside! Want it to be on it’s own line instead? Use $$mathstuffinhere$$for whenever you want an equation to appear on its own line.

In beginning as you learn things, use the snippet view on the side from the LaTeX extension to pick symbols but after a while, you’ll come to remember what you need and can type them out yourself. LaTeX commands start with a backslash \ so you can type out those fancy symbols whenever you’re in math mode (inside the dollar signs).

Quick tips

Now some general tips in no particularly order

  • Need sections? Do \section{name of section}
  • If you have sections, you can generate a table of contents \tableofcontents
  • If you want another page you can do \newpage
  • Need a list? Do \begin{enumerate}\end{enumerate}and type instead \item whateveras often as you need

Say you want to type out something like Big O. You can do \mathcal{O}(whatever)

So for example O(g(n)) would be \mathcal{O}(g(n)) and output:

Image for post
Image for post

Need Omega instead? Do \Omega(whatever)

Image for post
Image for post

More Resources

Here’s two great resources for reference:

Learn LaTeX in Y minutes

LaTeX Reference Sheet

For something more in depth, you could follow the Overleaf guide here for learning everything about LaTeX

Notes

I might come back and improve this article, but the main intention was to help my friends to get started using LaTeX on windows for school work! Hope it helps and good luck!

RU 2022 CS+Econ! Artist, GameDev 🥞

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store