A LaTeX Course for UoA Students
A HTML version Instructor: Theo J. Mertzimekis
Home > Basic Commands
Main menu
» First Steps
» Basic Commands
» Math equations
» Thesis template
» Bibliography
» Examples
» Useful Links

 

University of Athens

Questions? Comments?
 
Basic Commands

We will now cover some of the basic LaTeX commands. But before that, we will say a few things about the structure of the LaTeX source file.


The structure of the source file

As we have seen in the previous section, a source file (extension .tex) is required. This file is processed by LaTeX and the sequence of commands is scanned and translated. The file is divided in two parts:

  • The preamble is the upper top part of the source file, including all commands and options defined before the \begin{document} command. In the preamble we load all necessary packages and set needed options for the document.
  • The actual document with some formatting commands. The document ends with the command \end{document}. Everything placed after that is ignored by LaTeX and not processed.

Environments

LaTeX uses environments for certain operations or objects. You may center a part of the document by placing it in a center environment:

\begin{center}
text to be centered
\end{center}

or you may include a math equation (see next section) with the equation environment:

\begin{equation}
x^2+y^2=1
\end{equation}

A user may define his/her own environments in the preamble and use them throughout the text.


Commands

All LaTeX commands may appear in one of the following forms:

  • A backslash and some characters (letters only). Such commands are case sensitive and are terminated by a space or some non-letter character e.g. \large or \em\Alpha (the former increases the font size while the latter produces a capital A in italics).
  • A backslash followed by some special character, such as \% or \$
Some commands require an argument, which is included in curly braces {} immediately after the command name e.g.

\hspace{20mm}

Sometimes, commands provide options which are defined in square braces []. The general syntax is then:

\commandname[option1,option2,...]{argument1,...}

e.g.

\includegraphics[height=40mm,height=30mm]{somepicture.png}


Comments

Comments are parts of code that are useful for describing the source file or act as reminders. They are ignored by LaTeX. Comments are implemented in LaTeX by placing % at the beginning of the comment. All characters following % are ignored. e.g.

This is the famous Einstein relation % E=mc2 ** in-line comment
\begin{equation}
E=mc^2
% It describes the relation between mass and energy ** separate line comment
\end{equation}


Special characters

There are ten special characters that are reserved for LaTeX. They are used for several operations, typically producing no direct output. These are the following characters:
# $ % ^ & _ { } ~ \
They can be included as normal characters in the text by placing a backslash in front of them:
\# \$ \% \^ \& \_ \{ \} \~ \textbackslash


Lists (bullets, enumerations)

An enumerated list is generated in the enumerate environment. Every numbered bullet is specified with the command \item.

\begin{enumerate}
\item
Richard Feynman
\item
Roger Penrose
\item
Peter Higgs
\end{enumerate}

A bulleted list is generated by the itemize environment.

\begin{itemize}
\item
Richard Feynman
\item
Roger Penrose
\item
Peter Higgs
\end{itemize}

Of course, lists can be nested to any level. See similarities and differences in this example file [TeX][PDF]


Quotation Marks

The proper use of quotation marks in LaTeX is `` for the left and '' for the right ones, instead of " " for both. babel will translate that to language-specific quotes in case needed.