Writing Reports using LaTeX

This blog post serves as a gentle introduction to LaTeX, the documentation preparation system and documentation markup language.


This semester I decided to write my reports from my Analysis of Algorithms class in LaTeX. This was not a difficult task to accomplish, it actually made writing these reports easier (and prettier). Before diving into installing LaTeX packages and setting up your first LaTeX document, let us begin by looking into the history of LaTeX.

History behind LaTeX

TeX is a typesetting system written by Donald Knuth in 1978 and is still used for typesetting complex math formulas today. LaTeX is written in TeX and, like Tex, was designed “to allow anybody to produce high-quality books using a reasonably minimal amount of effort, and to provide a system that would give exactly the same results on all computers, at any point in time”.

LaTeX/TeX is still quite popular in academia in areas such as mathematics, sciences, and economics. You may have actually read a few books that were written in LaTeX (and you didn’t even know). But, did you also know you can create beautiful resumes and CVs with LaTeX as well? Excited yet? Let’s begin installing LaTeX on your machine!


On Windows 7/8, download MiKTeX from here.

On Mac OS X, download MacTeX from here.

On *Nix System, just check your distribution’s package manager for “xelatex”.

If you have any issues installing LaTeX, just follow this link for more download instructions.


This is an example from a report I wrote in my Analysis of Algorithms class. Remember that LaTeX can still be used for all kinds of documents (not just computer science reports).

% File: example.tex
% Author: TJ Maynes
% This is a comment!!
\usepackage[left=0.7in, right=0.7in, top=0.7in, bottom=0.7in]{geometry}
    Author={TJ Maynes},
    Subject={TJ Maynes Project1},
    Keywords={insertion sort, quick sort, merge sort, algorithms, undergraduate},

Above is a portion of code that serves as the “header” of your LaTeX document. The header of the page includes the documentclass, packages, specific fonts, etc. The “header” can be extended to include much more than this including custom layouts for various kinds of documents. You can look here for more information on creating your own .sty files.


\title{Asymptotic Notation and Sorting Project}
\author{TJ Maynes}
\date{October 15, 2014}


\textbf{1 Theory}

\textbf{1.1 Insertion Sort}

Insertion sort is a sorting method that starts at a single element in an array and then increments the rest of the elements in an array. Pseudocode for implementing an insertion sort is provided in Algorithm 1.

  \For{$i=1$ to $n$}{


    \While{$j > 0$ and {$A[j] < A[j-1]$}}{
      $\mathtt{Swap}(A[j], A[j-1])$


Below is a table of CPU times (in milliseconds) from running an increasing array of various instance sizes on mergesort. \\

    & \multicolumn{10}{c}{Mergesort}                                                               \\
    & \multicolumn{10}{c}{Instance Size}                                                           \\
    & 10000  & 20000  & 30000  & 40000  & 50000  & 60000   & 70000   & 80000   & 90000   & 100000  \\
    1   & 20.736 & 36.352 & 55.552 & 81.408 & 98.816 & 118.528 & 141.568 & 159.488 & 192.256 & 206.592 \\
    2   & 17.920 & 36.608 & 63.488 & 74.496 & 93.952 & 113.664 & 142.592 & 171.264 & 185.856 & 198.912 \\
    3   & 17.408 & 36.352 & 56.320 & 81.152 & 94.464 & 114.432 & 137.728 & 169.984 & 191.488 & 208.384 \\
    4   & 17.664 & 39.680 & 59.904 & 78.592 & 94.464 & 118.016 & 142.080 & 161.536 & 178.432 & 207.360 \\
    5   & 17.408 & 36.352 & 55.552 & 75.264 & 98.048 & 115.200 & 149.760 & 165.632 & 179.456 & 212.224 \\
    Avg & 18.227 & 37.069 & 58.163 & 78.182 & 95.949 & 115.968 & 142.746 & 165.581 & 185.498 & 206.694

% this is another comment!


Above is the portion of code that makes up the “body” of the LaTeX document. The body is where all the contents of your document are contained. In example below, I have included a Title, Author, and Date Tag (which is created by the \maketitle tag), an Algorithm function and an example table of CPU clock cycle times in Milliseconds.


To compile your LaTeX file to pdf format, run the following command.

xelatex example.tex

If you run into any issues on compilation, first read the compilation error and enter ‘r’ to finish compilations.

You can also use an online LaTeX editor such as WriteLaTeX.com.


Many LaTeX concepts can be learned from the example file, however you can learn way more by just diving into LaTeX (which ultimately helped me the most). Also, I feel as though LaTeX has helped me better structure and think through my reports for class. I hope this post was of some use to you!

Please comment below with any questions or concerns. Thanks again!

Extra: Here is an example of a LaTeX resume.

Free Templates


Update November 2014

Lately, I haven’t had very much time to write blog posts and work on the projects that I want to work on. Instead Analysis of Algorithms and undergraduate research has taken a significant portion of my time. However, I did start writing my papers in LaTeX which has actually been a fun experience and pretty easy to learn (and you get pretty reports)! Also, I’ve started to gain in interest in Video Streaming development from the undergraduate research project that I am working on. My time management has been out of wack lately too, need to fix this problem. My algorithms class has been kicking my butt, however I’m enjoying the material I am learning - especially dynamic programming (very interesting concept). You can find the algorithm projects that I have been working on here.

Jekyll is Awesome

This post is for readers/friends who want to get started on their own blog, but don’t know where to start.

Over the years, I’ve had a countless number of conversations with programmer friends about how awesome Jekyll is and how awesome Github is for letting you host your own website/blog for free. However, the usual responses from friends include:

  • "Jekyll sounds too difficult to setup and maintain."
  • "what is git?"
  • "Git-what??"
  • "why not Wordpress?"

Jekyll is a static page generator written in Ruby. In this post, we’ll be using Jekyll to generate our blog. Also, with a few commands in terminal, you’ll have a working blog up in less than a few minutes (depending on your connection speeds). Here is a link to the Jekyll website.

git is a open source version control system designed for small and large projects. Many developers/companies are using and supporting git everyday. I myself use git everyday for various small and large projects that I am working on. In this post, I will not get into the specifics of how to use git, however you can learn more about that by youtubing “git tutorials” or checking out this link.

Github is a website that allows you to contribute, share, and show off your git repositories to the world. Also, Github offers a free web hosting service called Github Pages, which is what you are going to use to get your Jekyll-based blog running on Github. Bonus: here is a link by Tom Preston-Werner called the Git Parable.

I’ll get to why I don’t recommend going the wordpress way at the conclusion of my post.

Don’t be afraid of what comes next. I’m going to try and explain everything as clearly as I can in this post!

Getting Started with Jekyll

  1. Your machine is using a unix/linux operating system.
  2. You are used to using a command line interface.
  3. You have ruby installed on your machine.
  4. Today, is not the first day you have heard the term HTML, CSS, or Javascript (or ruby).

Check to see that you have ruby gems installed on your machine. You can check by finding the verion number typing using the following command and pressing enter in Terminal.

gem -v

If you have ruby gems installed on your computer, please skip to Part three. If you don’t have ruby gems (no version number appeared) then, please read Part two.

Install ruby gems by going to their website and downloading the TGZ file. After downloading, change directory in terminal to designated download folder. Next, copy and paste these command into terminal and press enter:

tar xvzf rubygems-{ version_number }.tgz
cd rubygems-{ version_number }
sudo ruby setup.rb

Ruby gems should now be installed on your machine, check by entering the following command:

gem -v

You should now see a version number, which will prepare you for Part three.

Install Jekyll on your machine by entering this command in terminal (within a desired directory):

gem install jekyll

Next, change your directory to your documents (or where you please). Then type the following and press enter:

jekyll new my-site

This will create a jekyll folder called my-site. Next, change directory to my-site, then enter the following command:

jekyll serve -w

This will generate the static files from that directory into a working website folder called _site and will start a ruby webserver pointing to that folder.

Next, go to your web-browser and type “localhost:4000” and press enter.

localhost-screenshot You should be staring at what the above example displays. Congratulations! This might just be your first jekyll-based website!

If you have any problems setting up Jekyll, read the documentation page here!

Getting started with git

You’re going to need git on your machine. If you already have git on your machine then you should skip to the Important Git Commands section.

For OSX users, go to this link to download git directly from the git website.

For Linux users, in terminal enter:

sudo apt-get install git

First, make sure you update and upgrade your packages to get the latest version of git!

Git Commands

The three git commands you will primarily use for “publishing” your website/blog:

Again, I will not be going over how git works because that is a blog post in itself. Take some time learning git before getting started with Github (it won’t take long to understand how git works)!

Check out this link for more information on using git.


My biggest reason against using a wordpress as a blog platform for a software developer is that its just not modern platform anymore. Whereas with Jekyll, you learn alot about modern (important) technologies like git and github along the way (as well as a little Ruby). I highly recommend that you pursue learning more about web design and development regardless of your current title.

Feel free to send me an email if I have made any mistakes in this post! Thanks for reading!

Also, check out this link for more information on using the free website hosting service, Github Pages!