LaTeX source
View 1
View 2
View 3
Whole example
Let's examine the contents of a simple LaTeX file which has been used as a first example in this tutorial. First we must take a quick look at LaTeX syntax.
LaTeX files usually have a .tex extension. They consist of plain text interspersed with some LaTeX commands. The word command may sound scary. But don't worry. When you are beginning to write a LaTeX document, you really do not need to learn a new programming language or hundreds of commands. Basically you begin so that you get a simple template like the sample file below. Then start writing your own text inside the sections. The body text of paragraphs is simply plain text. Eventually you will need to write some commands but those you can usually copy and paste from other documents or templates.
When you want something special to happen, you must write a LaTeX command. The commands begin with a backslash and most of them want also parameters, which are enclosed in curly braces after the command. For example, write \section{My First Heading} to begin a new section of text with heading "My First Heading".
The names of the commands are quite intuitive. For example, if you look at the sample file below, you can easily guess that \title is the title of the document, \begin{abstract} starts the abstract text, and so on.
A comment line begins with a percent symbol (%) and continues to the end of the line.
That's all you need to know about the syntax now.
Note: Here we just want to analyse the commands and structure of a LaTeX file. That's why we have removed most of the text content of the paragraphs. You can get the same file with more text here.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\title{Introduction to \LaTeX{}}
\author{Author's Name}
\maketitle
\begin{abstract}
The abstract text goes here.
\end{abstract}
\section{Introduction}
Here is the text of your introduction.
\begin{equation}
\label{simple_equation}
\alpha = \sqrt{ \beta }
\end{equation}
\subsection{Subsection Heading Here}
Write your subsection text here.
\begin{figure}
\centering
\includegraphics[width=3.0in]{myfigure}
\caption{Simulation Results}
\label{simulationfigure}
\end{figure}
\section{Conclusion}
Write your conclusion here.
\end{document}
If you have installed MiKTeX and WinEdt or TeXnicCenter (see help for installation), the LaTeX processing of the above document is very simple. Open the .tex file in your editor. Then depending on the editor do the following:
.
.
Then click the "Build and view current file"
button. 1
You will get a PDF document with all formatting and layout applied.
One of the main advantages of LaTeX is that it takes care of formatting the document. The user can concentrate on creating the information content of the document and he doesn't need to bother about fonts, page breaks, placing of figures, etc.
The so called document class defines the formatting of the document. LaTeX provides many standard document classes but you can also use other styles. For example, conferences often provide their own document classes that you can download. Changing the formatting of your document is very easy. You just change one line of text that specifies the document class to be used. For example, a standard article style is selected using the line \documentclass{article}. Here are some examples of different styles and the result as a pdf:
If you are looking for the LaTeX style files we have used in these examples, you can find links to them on our Getting Help page.
If you are interested in the details of the sample file, here you go:
logo.)
1 If your document contains references and this is the first time you are compiling this document in TeXnicCenter, more than one LaTeX run is needed to get all references right: Click "Build current file". Wait until the processing is finished. Then click again "Build current file". And finally click "View output" to see the resulting PDF file. Later you can just click once "Build and view current file" and you see the PDF immediately.