Skip to main content

LaTeX: Introduction - First Document

Let us start with a simple $\mathrm{\LaTeX}$ document. Open your text editor (Texmaker, TeXnicCenter, TeXworks, etc.), then go to File>New, and paste the following:

Save this and make sure the file has .tex extension. You should have something like this
SampleTeX.tex in Texmaker
In Texmaker: Press F1 to compile and view the output (Mac users should manually click the blue right arrow next to the paste button, because F1 won't work). The output is in PDF format with text on the top-left corner of the page that says the statement in Output 1. Now let us investigate these line by line. $\mathrm{\LaTeX}$ document always starts with \documentclass which sets the document you are to create. In this case the document class is article, {article}, with font size option set to 12 point, [12pt].
Output 1: SampleTeX.tex

All $\mathrm{\LaTeX}$ tag always start with backslash (\), use braces ({}) to enclose arguments, and brackets ([]) to enclose options of the arguments.

Click here for list of document classes and options. Proceeding to the third line, we declare the beginning of our document. This implies that anything between this line and its corresponding end (\end{document}) will be included in the output.

The block of codes from \documentclass[12pt]{article} to the line before the \begin{document} is sometimes called the preamble. This is where you setup the properties of your document.

You can add more codes in the preamble to customize your document as we will see later. The text inside our article is coded as

The output simply returns the plain texts 'The sum of' and 'is'. $\mathrm{\LaTeX}$ reads alpha-numeric characters, just like typing in any word processing software. But the real thing occurs when you start modifying the font, like into mathematical form. Plain text are transformed into math style when you start putting dollar ($) sign both in the beginning and end of that text. Like in our code we have x_1 + 3x_1 and 4x_1 both enclosed with $ separately. Finally, underscore is use for subscript. Now, what about if we modify it into this?

The \LaTeX is a special function for proper formatting of the $\mathrm{\LaTeX}$ name, and \maketitle is a function that includes the header (title, author, and date) of the document set in the preamble. Both \LaTeX and \maketitle are example of $\mathrm{\LaTeX}$ functions that do not take any argument.

$\mathrm{\LaTeX}$ ignores white spaces.

Thus, the following returns the same statement as in Output 1.


Comments