My LaTeX template

After about four or five years, I’ve become quite proficient at writing reports and documents with LaTeX. I’ve recently been asked by a couple of friends to send them a sample document which could be used as a reference.

The basics

You’ll be writing (or typesetting) plain text to a file. This file, usually with the extension .tex, is the source code or markup that’ll be compiled. On compilation, you’ll get a DeVice Independent (.dvi) file. This is an intermediate file format that can be converted into a variety of suitable formats by driver programs. You can have a PostScript driver, a PDF driver, a PNG driver or a driver for displaying the file on screen.

Programs

You’ll need the programs latex, dvips, gv, and pdflatex. These programs usually come in a package called tetex-base on Linux. You’ll also find it handy to use the DVI viewer xdvi. On windows, MikTeX provides the above tools. The DVI viewer is called yap (included with MikTeX.)

Our first document

LaTeX “markup” is a lot like XHTML. You can group a block of text with the \begin and \end tags (like div or a in XHTML):

\begin{document}
...
\end{document}

You can issue commands that do not need a closing tag (like img):

\newpage{}
\section{Introduction}

You can find numerous tutorials on the web about the syntax, so I won’t go into that. Our first complete document would be:

%% first.tex : Our first document
\documentclass{article}
\begin{document}
    Hello World
\end{document}

To get a PDF of the document, issue the following commands [[you can also call pdflatex or dvipdf to skip intermediate steps]]:

latex first.tex
dvips first.dvi -o first.ps
ps2pdf first.ps first.pdf

It’s really that simple. The major drawback of this is that you need to key in these commands every time you want to view you document, which gets very tiring in a short while.

Samples

I never start a document from scratch. I’ve posted my template document that I’ve built over the years. Feel free to use and share it with your friends.

Comments are closed.