Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.


a guide to using LaTeX document preparation software

Document Structure

Each LaTeX program has these three general parts:

  • Preamble
  • Document Environment
  • [Optional] Special Pages

The Preamble includes defining the type of document you wish to create (such as an article, book, report, etc.) as well as a call to any packages you wish to use in addition to the default packages. For example, if we wish to write a journal article with 11pt font and use the package “graphicx”, our first two lines of our LaTeX program would look like:

The Document Environment is the body and actual content of your document and includes texts, tables, figures, images, equations, and anything else you wish to include in your actual document. You may include header information such as the title, subtitle, author, date, and abstract. You may also format it to your liking through the use of chapters, sections, paragraphs, and appendices. The commands and formatting options available vary by document class, but they are all similar in nature.

You begin and end this section of the document through the commands:

first line: \begin{document}, second line: ..., third line: \end{document}




In general, the word environment refers to a section of your LaTeX edior that follows a certain format, has its own reference scheme, or has specific command options different from the rest of the document, and it is characterized by \begin{} and \end{} commands. The document environment is the main environment, but within that you can create environments for figures, tables, equations, etc.

The Special Pages are optional and may include such pages as an index, glossary, and/or bibliography. This is a more advanced topic not covered in this guide, but we do review how to create a simple bibliography using BiBTeX.

Document Classes

The document classes specify what type of document you want to create. Though there are many predefined formats, there are really only two that students use most often:

  • Article: used when writing scientific journal articles, presentations, short reports, etc.
  • Report: used when writing longer reports, reports with chapters, small books, theses, etc.

The document class must be specified in the Preamble, before the body of the document, so that LaTeX knows how to format the content. You do this with the command:




The commands in the square brackets are optional and are used to override any defaults. At the end of this guide are templates for you to get started with LaTeX. There will be templates and examples for both document types.

The Document Environment

The first thing to include in the document environment (after the \begin{document} line) is the information on the document’s title, author, date, etc. The commands to create this first part of your document is:

first line: \title{LaTeX Guide}, second line: \author{John Doe \and Jane Doe}, third line: \date{\today}, fourth line: \maketitle





Note that you can include the actual date if you don’t want to print today’s date.

If you wish to include an abstract, that would go next using the commands:

first line: \begin{abstract}, second line: This is the text of the abstract..., third line: \end{abstract}




Now the remaining part of the document is the main body, including your text and any tables, figures, equations, etc. You type it up in the same manner you want it to appear, but you’ll have to use some LaTeX commands to reformat, insert figures, create tables, etc. The text is typed exactly like you would in Word or another word processor, but if you want to change the font type, size, color, etc., that would require a LaTeX command as well. More detail on the text and formatting options follows later in this guide.

Many people like to organize their documents by the use of paragraphs, sections, or chapters. Each defines a new part to your document but the formatting is different, as is the way it is treated in a table of contents, if you decide to use one. They may vary by document class, but in general the formatting are as follows:

  • A paragraph puts the title in bold, but the text of the paragraph follows immediately after in normal font on the same line:

illustration showing the paragraph title and text in different fonts


  • A section includes a number or other counter, puts the title in bold and a large font, but the text follows in normal font on the next line with an indent:

illustration showing the section title in a large font and the text following in a smaller font and indented to the right




You could also include subsections (or even sub-subections), which will continue the numbering scheme of the larger section:

illustration showing the subsection and subsubsection titles in large font and the text underneath the subsection and subsubsection in smaller font






  • A chapter includes a number or other counter, puts the title in bold and in a very large font, starts a new page, and the text follows in a normal font on the next line.

illustration showing the chapter title as large and bold with the text following in normal font with a space between the chapter title and the start of the text.




Typically the ordering, from highest level to lowest level, is chapter, section, subsection, sub-subsection, paragraph, and subparagraph. However, these are all optional, and furthermore, chapters are only available in the book and report classes. You will most likely only need to use the section, subsection, sub-subsection, and paragraph commands:

first line: \section{section title} then the section text; next line: \subsection{subsection title} then the subsection text, next line: \subsubsection{subsubsection title} then the subsubsection text, next line: \paragraph{paragraph title} then the paragraph text.







If you wish, you may also include a table of contents at the beginning of your document. You don’t need to do this manually; if you use the chapter, section, and paragraph commands this will automatically populate your table of contents. To include a table of contents in your document, simply insert the following command wherever you wish it to appear in your final document (usually after the title or abstract):

command: \tableofcontents



Note that when you add Table of Contents and other lists of references in the document you need to compile the document twice to make sure that the page numbers are correct.

Creating a Bibliography

If you want to create a bibliography or references page, you can simply do it by embedding it in the LaTeX editor itself. You would format it (including title, typesetting, indentations, line breaks, etc.) and type in the text itself. You would probably want to create a new page, insert a header saying References or Bibliography, and then begin the actual list of references. It would look similar to as follows:

This is the simplest way to create a bibliography for beginners (the closest to the way you would do it within Word or another word processor), but it can also be time consuming.

As an alternative you can use BiBTeX to create your bibliography page. It’s a few more steps, but when you have many references and citations, it should actually save you time. You also don’t have to manually format the page, as the BiBTeX package will do it for you. Furthermore, if you write several papers or articles citing the same reference(s), you don’t need to continually create a new bibliography section. You can refer to the same set of references in several documents, yet each individual article to report will only include in its reference page only those references that you cite in that particular document. Therefore, if you are willing to take a little extra time to learn how to use BiBTeX, it can save you a lot of time and effort in the long run. It’s actually pretty simple once you learn how to use it! We highly recommend this route.

To create a bibliography using BiBTeX, instead of embedding the references in the actual LaTeX editor itself, you create a separate file. To do this, first open a new LaTeX editor. It is in this new, empty file that you will create your references file which you will refer to in your main LaTeX document. Now within this new file, you compile your references. A typical entry will look as follows:

first line: @article{ref1, - second line: author={Doe, J. and Smith, J.}, - third line: title={Guide to LaTeX}, - fourth line: year={2014}, - fifth line: journal={University Library Journal}, - sixth line: volume={99}, - seventh line: number={1}, - eighth line: pages={1-10}, - last line: } (closing bracket)








The above creates a references to an article with tag ref1. The word after the @ symbol tells LaTeX what type of reference it is, and thus how to best format it. There are several other types of references, including books, chapters, theses, technical reports, and proceedings, among others. The type of reference dictates which field are required to correctly create the reference. Field may include author, title, edition, journal, month, year, publisher, pages, series, school, volume, etc. The following table summarizes the available reference types and required fields:

table showing standard BibTeX entry and field types















The table comes from Wikipedia’s article on Bibliography Management in LaTeX, the link for which is also provided in the resources at the end of this guide. That resource, along with some of the others, also provides a discussion of when to use which reference type and other formatting topics.

Once all entries have been completed, it is time to save the file. However, be careful! When you save it, you are no longer saving it as a .tex, which is the default extension. Instead, use the .bib extension. For example, you might save your reference document as Ref.bib. Be sure to keep this saved in the same directory as your original LaTeX document, the one to which you wish to apply the references. Once it is saved, you can close the bibliography file and return to your main .tex file of your document. To create the bibliography, at the end of your document (after all your other content but before the \end{document} line), you use the following commands:

first line: \bibliographystyle{plain}, second line: \bibliography{Ref}



The first line specifies the style and formatting of your bibliography, which you may want to change depending on your needs. For example, an instructor may expect a certain format if you are submitting a class project, or a journal may require another format if you are submitting an article for publication. There are formats that adhere to APA and MLA, in addition to others. One of the links in the resources provides information on the different bibliography styles available and what they will look like.

The second line provides the name of the ‘.bib’ file that contains the list of reference. In this example, the references are compiled in Ref.bib.

Finally, whether using BiBTeX or embedding the bibliography, you will likely want to cite the references throughout your document. Notice that in either form, we assigned a tag (ref1 in this case) to each of our references. These tags must be unique, because we will use them for citations. Within your document, whenever you wish to cite a reference from your bibliography, you use the following command:

command: \cite{ref1}



Note that when you use this, LaTeX will format it according to whatever bibliography style you’ve chosen (or, if embedded, according to the document class). However, it will not add things like parentheses, so you must include that yourself if you need them.

Use of Color in Edit Mode

Within your editor you have the option of using syntax coloring as you type in commands. This option is found in the menu under Format->Syntax Coloring->LaTeX. When this is turned on, the text is no longer all black but will change color based on the type of syntax. The advantage to using color is that you can quickly identify what is a command, what is text, etc. This is extremely useful for finding typos or when troubleshooting after getting an error message. LaTeX syntax coloring uses the following scheme:

Black is used for the actual content and for the arguments inside of brackets (e.g., section titles, author name, the document class name, etc.)  Blue is used for basic LaTeX commands that do not require an ‘end’ statement; these will typically lead with a backslash (‘\’)  Navy is used when you load packages, i.e. use the \usepackage command in LaTeX  Red is used for any unused line in the code, i.e. those that follow a percent sign (‘%’)  Dark red is used for symbols and special characters that function as LaTeX commands, such as ‘^’, ‘$’, and ‘{’ or ‘}’  Green is used when the commands define the start or end of a specific environment, such as figure, equation, array, theorem, definition, itemized list, enumerated list, centered, or bibliography environment (e.g., those that need and are defined by a \begin{} and \end{} commands)

Text Options

Even though you may feel like there is a lot of syntax and LaTeX commands, the majority of your editor will still be the actual text and content of your document. Though the format is already defined based on your document class, there will be countless occasions when you may want to override the defaults. Here are some basic text options:

Bold: \textbf{Here goes the text you wish to bold.} Italicize:  \textit{Here goes the text you wish to italicize.} or, alternatively, \emph{} Underline:  \underline{Here goes the text you wish to underline.} Use LaTeX editor font:  \textttt{Here goes the text you wish to output as a LaTeX editor font type.} Change font size:  Depending on what you need, here are some of the common ones, in order from smallest to largest: {\tiny Here goes text.} {\scriptsize Here goes text.} {\footnotesize Here goes text.} {\small Here goes text.} {\normalsize Here goes text.} {\large Here goes text.} {\Large Here goes text.} {\LARGE Here goes text.} {\huge Here goes text.} {\Huge Here goes text.} Change font color:  You first need to download and load the “color” package (\usepackage{color} in the Premable), and then use \textcolor{newcolor}{Here goes the text you wish to be colored}. The options available for “newcolor” are white, black, red, green, blue, cyan, magenta, and yellow.

















Note that, basically, when brackets are involved, the command is assigned only to the text in the brackets. When brackets are not used, the command is followed indefinitely until it is overridden by another. Most of these commands require the use of brackets, but some, such as font size, do not. The only time you may want to eliminate brackets is if, for some reason, you want a significant chunk of your document to be a different size than normal. Then you can use one of the commands without the brackets, but then you must be sure to revert back to normal size if you need it to be so:

\Large Here I will include a lot of text that will be two sizes larger than normal,  \normalsize Now the text resumes to normal size

Formatting options

Just as with text editing, there are lots of ways you may want to format your layout that is not standard in the default. Some of these are automatically done for you as you start a new paragraph or section, so it is recommended that you first run the code, review the output, and then make any additional modifications that you desire. For example, LaTeX will typically indent new paragraphs on its own when you start writing text on a new line in the editor, so you needn’t include a command to indent for every new paragraph you write. However, if you look at the published document and decide that it needs some modifications, here are some basic formatting options:

New line: \\ or \newline (or in the case of paragraphs, you can leave a blank line in between) Centering: This is an environment:  \begin{center}  Centered text goes here... \end{center} Indent: \indent No indent: \noindent New page: \newpage Print the text verbatim, even if it would otherwise be code. This is an environment: \begin{verbatim}  Anything you want printed exactly how it appears in the editor goes here... \end{verbatim}


LaTeX makes it easy to create either enumerated (numbered) or itemized (bulleted) lists. To create a numbered list, use:

\begin{enumerate}; \item This is the first item; \item This is the second item; \item And so on; \end{enumerate}






Similarly, if you wish to create a bulleted list, use:

\begin{itemize}; \item This is the first item; \item This is the second item; \item And so on; \end{itemize}

Symbols and Special Characters

Another one of the ways that LaTeX is different from a typewriter or a traditional word processing program is the way that special characters are treated. Some symbols are used to communicate with the typesetter. Some other symbols are used to typeset special characters. So, unlike in say, Word, what you see is not what you get.

Symbols used as commands

LaTeX has embedded commands in the form of symbols. For example, a percent sign (%) at the start of a line will ignore anything in that line (it acts as a comment for the editor and will not show up in the document). In these cases, to override LaTeX reading it as code, you need to add a backslash to the front of the symbol. Here are a few common examples of when you would need to do this:
Curly brackets: \{ or \} Dollar signs: \$  Ampersand: \&  Percent:  \%  Hashtag: \#





Symbols that are typeset as other symbols

Depending on how the font is set up, LaTeX will typeset certain symbols differently, for example, the < (left than symbol) and the > (greater than symbol) will be typeset as the upside down explanation point and the upside down question mark used in the Spanish language. You can typeset symbols literally in a couple of different ways.

  • Use symbols in an equation environment - see next section
  • Use commands such as \textless{} for < and \textbar{} for >
  • Change the font encoding (This is a bit more advanced)

Typesetting special characters

In select cases, , the keyboard version isn’t sufficient. Here are two common situations where you would want to avoid using the traditional keystroke:

Quotes: ``Here goes text’’ .  Note that we do not use the double-quotation key on your keyboard for the left quotation; instead you use only the single left quotation key (`, located next to the ‘1’ key).  For the right you can use either the standard double-quotation or the single right quotation twice. Dashes and hyphens: - for hyphen, -- for long dash





The LaTeX/Special Characters page of the LaTeX WikiBook contains more information.


Mathematics and Equations

One of the main benefits from using LaTeX over other word processors is its ability to easily and expertly create professional-looking mathematical equations. Though not required, we recommend downloading and utilizing the “amsmath” package (\usepackage{amsmath} in the Premable) as it has some useful features for displaying equations.

If you try to use a mathematical term in your text without the proper environment, you will get an error. Therefore you need to tell LaTeX what is a mathematical expression, term, or equation. If you want to show in line with the other text, you simply use a dollar sign before and after the expression:

       The area of a circle is calculated as $2\pi r^2$ where $r$ is the length of the radius.

If, instead you wish for it to stand alone, you have one of two options. The quickest option is to start a new line in the editor and enclose your mathematical formulation with a series of square brackets and slashes:

        \[ f(x) = \frac{1}{x^2} \]

This will center your function on a new line in your document, but will not number it. If you are interested in numbering your equation or if you have more a more complex expression, you may want to use the equation environment:

        \begin{equation}\label{eq1}; f(x) = x^5 + 4x^3 + 3x^2 + 7 ; \end{equation}

When using the equation environment as displayed above, LaTeX will number your equation so that you may reference it in the text. The tag for the equation is in the \label command – in this example, we tagged the equation as eq1. Now to cite this in the text, you use a command similar to the citation command from the references (this will print the number only, so you may want to put the word Equation before it):


If you want to use the equation environment and don’t want it numbered or don’t need to reference it later, you can just add a asterisk and eliminate the label command:

         \begin{equation*}; f(x) = x^5 + 4x^3 + 3x^2 + 7; \end{equation*}

There are many cases where you will want to use a multi-line equation, such as when you want to show the steps to simplifying a function. To do that, you need an equation array environment:

         \begin{eqnarray*}; 	P(X\le 3) &=& P(X=3) + P(X=2) + P(X=1) + P(X=0) \\ 	&=& 0.10 + 0.25 + 0.05 + 0.05 \\ 	&=&  0.45;  \end{eqnarray*}

Notice that, in this example, we used an asterisk so that it will not be numbered. If you want to number the array, just remove the asterisk. Additionally note the use of the ampersands. These will define the array at the point where they should line up. So in this case, all the equal signs will align on different lines. Recall that the double backslash will begin a new line.

There are many nuances of mathematics and equations in LaTeX that we will not get into in this guide, so we recommend reviewing the resources for more details. Additionally, the document containing the common LaTeX symbols also includes mathematical symbols and some information on creating equations. Three things we will note here:

  • Generally, the spacing doesn’t matter in an equation environment – LaTeX already has default spacing depending on what you type. If you wish to add more spacing than what is given, a quick solution is using \; , which will add more space. You can use this several times in a row to create even more space: \;\;\;\;
  • Text in an equation will be read like math symbols, so letters will be italicized and won’t be spaced properly. To use text within a mathematical environment, use the \mbox{Regular text...} command.
  • You can use brackets whenever you want to assign a command to more than just the sole next character to appear. For example, if you want x^12 to appear, you must use x^{12} rather than x^12, which will give you x^12.

Figures and Tables

Figures and tables can easily be incorporated in your document. Though not required, we recommend downloading and utilizing the graphicx package (\usepackage{graphicx} in the Premable) as it has some useful features for handling graphics.

Figures should be saved as separate files in one of the following formats: .jpg, .png, .pdf, or .eps. The easiest thing to do is the save it in exactly the same directory as your editor file, as this is where LaTeX will go to look for figures. You can also create subfolders within that directory and refer to them that way. In this case, you will have to use an address format with forward slashes – e.g., if you save the figure fig1 in a folder called Figs, which is in the directory of your editor, the file name will look like Figs/fig1.pdf. If you use fig1.pdf LaTeX will assume that it is in the same directory as the editor. There are ways you can change the default directory for figures, but we won’t go into that here.

Once you have all your figures saved in the proper format and in the appropriate folder, you can input them into your document using the following commands in the editor:

        \begin{figure}[placement] ; \centering; \includegraphics{Figs/fig1.pdf} ; \caption{This is the caption.} ; \label{pic1} ; \end{figure}

This chunk of code will center and print the figure “Figs/fig1.pdf,” print a caption (“This is the caption.”), and tag it for referencing the text of the document. If you don’t want to center the figure, just remove the \centering command. Just as we did with equations, we can refer to this particular figure number with (again we may want to put the word “figure” before the reference since it only prints the figure number):


Recall that typically anything in square brackets ( [ ] ) after a command is where we insert options for that command. In this case we must put a placement option. The table below outlines what the options are for the placement, and what it will do:

     Specifier h has the Permission “Place that float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)”. Specifier t has the Permission “Position at the top of the page”. Specifier b has the Permission “Position at the bottom of the page”. Specifier p has the Permission “Put on a special page for floats only”. Specifier ! has the Permission “Override internal parameters LaTex uses for determining ‘good’ float positions”. Specifier H has the Permission “Places the float at precisely the location in the LaTex code. Requires the float package, e.g. \usepackage{float}. This is somewhat equivalent to h!”.

The table comes from Wikibooks’s Floats, Figures, and Captions page in their LaTeX guide. Note that it recommends using the float package if you want the figure to go exactly where you insert it in the editor. The guide also provides some information on more advanced figure formatting options, such as subfigures, changing the size, etc.

Tables are a bit trickier to insert in a document. They require more LaTeX commands and it is less straightforward than figures. A basic table will look something like this:

       \begin{table}[placement] ; \centering; \begin{tabular}{ | l | c | r | }; Name & ID & Gender \\; \hline; Ben & 1 & M \\ ; Jack & 2 & M \\ ; Amy & 3 & F \\ ; \hline ; \end{tabular} ; \caption{This is the caption.} ; \label{tab1} ; \end{table}

There is certainly a lot going on here. First we will note there are some elements that are the same in both the table and figure environments: the placement option, the centering command, the caption, and the label. These are all used identically, so you can refer to the discussion of figures for descriptions of these. What is new in the table is the tabular environment; this is what we need to include to actually create the table.

The { | l | c | r | } line, immediately following the start of the tabular environment, defines the format of the table. Specifically, we define the alignment of the columns and whether the columns are separated by vertical lines (rather than just a space). A single letter represents a column, with “l” meaning left-justified, “r” meaning right-justified, and “c” meaning centered. The vertical line, |, indicates that you do indeed want a vertical line printed in between those two particular columns (or at the left- and right-side of the table). You may also use two vertical lines, ||, if you want a double vertical line printed between the columns. If omitted, there will just be a space between columns. So, in the example above, there are three columns; the first is left-justified, the second is centered, and the third is right-justified. Additionally, all columns are separated by vertical lines, and table also has vertical line at the rightmost and leftmost sides.

The next few lines, before the \end{tabular} command, compose the actual contents of the table. The ampersands (‘&’) act as column separators, the double backslash (‘\\’) goes to the next row, and the \hline command inserts a horizontal line that goes across all columns. Note that the number of ampersands in each row MUST be equal to the number of columns minus 1 (because there should be one between each cell entry). If you wish to insert a horizontal line across only certain columns, you can use the following command (in this example it starts in column 2 and ends in 4, but of course can be modified to fit your needs):


We recommend you peruse the templates and resources to see more examples of how to create tables.

Just as we were able to create a table of contents for the document, we can also create a list of figures and tables easily. The table and figure numbers and captions will be included, along with their page locations. To include either a list of figures or list of tables, simply insert the following command(s) wherever you wish it to appear in your final document (usually after the table of contents):

       \listoffigures ; \listoftables