LaTeX: Tutorial

Getting started with LaTeX for CS111

TODO: This LaTeX tutorial has some stuff in it that’s specific to working with MATLAB. It might be good to factor that out. The original is here: http://cs.ucsb.edu/~gilbert/cs111/latex/

Resources

These resources will be useful for almost everything outside of the small scope of this tutorial. Thus, they are displayed prominently at the top.

Prerequisites

First and foremost, you will need access to a copy of LaTeX. You should be able to install a LaTeX distribution for nearly any operating system:

You could also use SSHFS, SSH and your CSIL account, rather than install these rather large distributions.

Alternatively, something like LyX is a great all-in-one solution.

Finally, we will need a favorite text editor and a copy of MATLAB.

Template directory

The template files are in the following github repo:

Here is a summary of the files:

File Explanation
latex_tut.tex LaTeX source file. Read through this carefully
Makefile Runs pdflatex latex_tut 3 times—just to be safe.
finitefern.m Matlab code used to generate figure.
finitefern.pdf PDF version of the figure generated in Matlab.
placeins.sty LaTeX package that is included so the FloatBarrier command can be used.

Run make in the template directory.

If your machine doesn’t have make, run pdflatex latex_tut (you may need to run this 3 times).

If you have some time, rubber is a much better alternative to make or the by-hand method.

Create a Matlab figure

The instructions to duplicate the figure (or replace it with your own) included in the template directory are simple. I used finitefern to generate my figure. Run the code and a figure should appear. Then save the figure as a PDF. Place the code that generated the figure and the PDF in the same directory as your LaTeX code.

Credits

This file was authored by Jeff Tyson, and refomatted for Markdown by P. Conrad

Related topics: