We recommend typesetting solutions to CS103 assignments in LaTeX. LaTeX is the standard for typesetting CS/math/etc. papers, and will likely come in handy outside of this course. With each problem set, we will also release a LaTeX template. As mentioned in class, the use of LaTeX is not required - you are allowed to use any text editor of your choice (Microsoft Word, Google Docs, etc.) as long as you are able to export the final result as a PDF that can be uploaded to Gradescope.

Getting Started

LaTeX is a bit different from word processors you may be used to in that you write in a markup language that is then compiled into the final document. To do so, you will need to use a LaTeX editor.

We recommend using an online editor such as Overleaf. The provided TeX templates should work straight out of the box - just copy and paste the entire template into the editor. And if you're working with a partner, Overleaf allows you to collaboratively edit LaTeX documents (similar to Google Docs).

You can also install a LaTeX editor for your computer such as Texmaker, TeXStudio, etc. These can offer more customization but may require some additional setup.

You may see an error message saying You must have 'pygmentize' installed to use this package. If that is the case, you will first have to install Pygments (this is the package we're using to get syntax highlighting for the code snippets in the template).

After doing so, if you see a message like Package minted Error: you must invoke LaTeX with the -shell-escape flag, or if you're still seeing the same You must have 'pygmentize' installed to use this package despite having just installed it, you'll need to add the "-shell-escape" flag to the command that the editor uses to compile (using the PdfLaTeX distribution). Usually you can find this in the settings or configurations for the editor.

Drawing Figures

You may find yourself needing to draw a figure in LaTeX, such as drawing a finite automata. Here are some good resources specific to getting pictures in LaTeX.

  • Finite State Machine Designer is a graphical interface for drawing out automata (similar to our DFA/NFA tool) which allows you to export the resulting graphic as TeX code. Pro tip: delete on Mac is fn-delete.

  • You may also choose to include an image created outside of TeX as an image (for example, if you design an automaton in our DFA/NFA tool or using some other image editing software, you can take a screenshot and add that image into your TeX submission). The Overleaf documentation on inserting images has some good guidance on how to do this.

  • A third option is to use the TikZ package allows you to draw all kinds of graphics in pure LaTeX. In particular, the automata library is helpful for drawing DFAs and NFAs. Here's an example with comments explaining how the individual drawing commands work: Latex_Automata_Example.tex.

General Resources

  • Overleaf Documentation for guidance on formatting and how to typeset mathematical expressions
  • Detexify allows you to draw the symbol that you are looking for and get LaTeX code (particularly helpful if you're trying to find something but you don't know what it's called!)