Get Started with LaTeX

by Ostatic Staff - Aug. 16, 2010

LaTeX, pronounced “La-Tec”, is a document preparation language that treats creating many types of document files like constructing a shell script. LaTeX uses a “What You See is What You Mean” interface, far removed from the WYSIWYG word processors like Word and OpenOffice. LaTeX is a programming language, but don’t let that scare you away. Like many things in open source, the learning curve may be steep, but the view from the top is fantastic.

Why Bother: Depending on your needs, digging in and learning LaTeX may or may not be worth your time. I first discovered LaTeX while taking a algebra in college. I needed to turn in papers with complicated algorithms and graphs, and spent hours pulling my hair out trying to line up figures using Word’s equation editor. Once I found LaTeX, my papers and equations were not only beautiful, they were so well received by the professor that he used them as examples for the rest of the class. I’m certain that I owe my A in that class to LaTeX. While LaTeX is most well known in academic circles, it’s also useful in creating any kind of document. Letters, envelops, reports, even entire books can be written and typeset using LaTeX. If you are serious about what you are writing, LaTeX is for you.

Write What You Mean: One of the biggest problems I have with Word and Word clones is formatting. How many hours are wasted world wide trying to get a graphic to line up just right, or how many times have you heard someone (maybe yourself?) curse at the computer because the word processor decided it “knew” what style you wanted to apply to a section of text? LaTeX is all plain text, no special proprietary document format, no sketchy xml file, just standard plain text. You declare implicitly what you want the text to look like, and then concentrate on writing, not formatting. Isn’t that what you really want to do with a word processor anyway?

Get Started: The first thing you need to do to get started with LaTeX is install a distribution for your operating system.

  1. Windows: MiKTeX
  2. Ubuntu: Available in the Universe repository
  3. Mac OS X: MacTeX

Once you have everything installed, you need to choose a text editor. Any plain text editor will do, but it is useful to find one with syntax highlighting support for LaTeX. Both MacTeX and MiKTeX include a good editor, and GEdit for Ubuntu has support for LaTeX, so those are all good places to start.

Next, choose a directory to hold your LaTeX projects. Create a HelloWorld directory, and put two files and two folders in that directory. Your hierarchy should look like this:


The two directories, img and tex, are to hold image and LaTeX documents, receptively. The files mystyle.sty and mydoc.tex are master code holding files designed to keep your documents clean and easy to read.

Put it Together: For our example, we are going to write a letter. Copy the following to the appropriate files:


\signature{Fred Jones}
\address{555 OStatic Lane \ Coolsville \ Ohio, 11111}

% put all the other packages here:



\begin{letter}{Director \ Fake Masks Co \ 1 Weird Road\ Moscow \ Iowa 99999}
\opening{Dear Sir or Madam:}


\closing{Thank You,}
\ps{P.S. I insist!}




% Use utf-8 encoding for foreign characters

% Setup for fullpage use

% Uncomment some of the following if you use the features
% Running Headers and footers

% Multipart figures

% More symbols

% Surround parts of graphics with box

% Package for including code in the document

% If you want to generate a toc for each chapter (use with book)

% This is now the recommended way for checking for PDFLaTeX:

%\pdffalse % we are not running PDFLaTeX
%\pdfoutput=1 % we are running PDFLaTeX


In the mydoc.tex file you’ll notice a line that reads: \input{./tex/letter.tex} . This line reads the letter.tex file from inside the tex directory into the document. Go ahead and create that file with some placeholder text inside of it. I got mine from here.

If you’d like to include an image, drop this code into your letter.tex file:


and simply replace pic.png with the name of the image you’d like to include.

Generate: Now, depending on your OS, you can either drop down into the command line or, well, press a button to generate your a PDF of your letter. Assuming you are going to drop down to the command line, you should now be able to run pdflatex mydoc.tex. This command will parse the LaTeX, build the letter, and create a pdf file, ready for printing, mailing, or whatever.

I’ve been deliberately oversimplifying the power of LaTeX in this article to make it easy as possible to get started. The truth is that LaTeX is powerful enough to handle everything from simple letters to the most demanding of writing projects. While the directory structure above is not really necessary for the letter we wrote today, you can see how complex projects could benefit from keeping the logic of the code separate from the text of the project. LaTeX has a steep learning curve, but its one that fun and satisfying. Personally, I don’t think I’ll ever launch a word processor to create a document again. Not unless I have to anyway!