Math, Tables, Figures

Mathematical Formulas

To write a mathematical symbol or formula anywhere in the text of the document, surround it with $ (dollar) characters. To write a formula in a separate line, put it in the equation environment. The latter is a numbered object and can be referred to in the text.

For example, the following code:

Given $x_i$, $i=1,\ldots,n$, the value of $y$ can be calculated as follows:
y=\frac{\left(\sum_{i=1}^n x_i\right)^2}{2\pi}
In formula \ref{eqn:abc} the sum is ...

will give the following result:

Tables and Figures

Tables and figures are floating objects, which means that LaTeX decides where to put them in the document. By default, LaTeX tries to put them at the bottom or at the top of the page, after their location in the LaTeX source code. Tables and figures are numbered objects and can be referred to in the text. 

Here is an example of a table:

\begin{table} \centering
\caption{My data\label{tab:MyData}}
Data Set & $n$ & Avg. Dev. \\
First  & 7   & 1.234 \\
Second & 120 & 15.555 \\

When compiled, the following table is placed somewhere in the document:

The caption is defined with \caption command. The tabular environment defines the content of the table, with the first parameter specifying the columns of the table. There, each letter denotes a single column that is left-justified (l), right-justified (r), or centered (c). The vertical bar (|) indicates where vertical lines should be placed in the table. Inside the table, columns are separated with & character and the lines are finished with \\. Command \hline introduces a horizontal line between rows.

To include figures from external files, put \usepackage{graphicx} at the beginning of the document. Then, use the following code:

\begin{figure} \centering
\caption{My figure\label{fig:MyFig}}

Command \includegraphics includes the picture from an external file (file.png in the example). The option width forces the figure to be rescaled to achieve a given width (80% of the text width in the example).

If LaTeX document is compiled directly to PDF, as explained in the Introduction, three types of picture formats are supported: PDF, PNG, and JPG.

Copyright (c) 2008, 2013 by Krzysztof Fleszar

The gadget spec URL could not be found