LaTeX syntax quick references

[ Home ] [ Back ]


% this is a comment

Basic document structure

\documentclass[options]{class type}


How to obtain a well organized source code

It is possible to recall external parts of code in order to obtain a simpler and more clear structure of your main source code by using of the \input{} command.

% Preamble:
\documentclass[options]{class type}

% body of your document



:!: Please note that in each .tex document (section_01.tex, section_02.tex etc.) you have not to put any line just like \begin{document} or \end{document}, or packages' declarations: these are just pieces of code recalled in your text!!!


The portion of code within \documentclass and \begin{document} statements.

Available document classes:

  • article (chapters are not supported)
  • report
  • book (two-side document by default)
  • letter

Basic class options:

\documentclass[a4paper,11pt]{class type}

The default font sizing is 10pt, but you can also specify 11pt or 12pt.

Core document

The code within \begin{document} and \end{document}.

Extensions (packages)

\usepackage[options]{package name}

Basic formatting syntax

LaTex supports bold, italic etc.

LaTex supports \textbf{bold}, \textit{italic} etc. 

You can also combine all these,

You can also \textit{\textbf{combine} all these}

Note that \textit{} and \emph{} produce the same italic output.

Other formats:

\textsl{slanted text}
\texttt{typewriter text}
\textsc{small caps}


A document can be divided using chapters, sections, subsections, sub-subsections and paragraphs.


New paragraphs are automatically created by leaving an empty line.

If you are using the book document class you can also use:




The \clearpage command is similar to \newpage, but forces LaTex to print all folating tables and pictures before the page break.


Vertical spacing:


Horizontal spacing:


Usually you will specify spaces in cm or mm, but other typographic units exist.


The \vfill fill command produces a rubber length which can stretch or shrink vertically. It is equivalent to a blank line followed by \vspace\fill.




First you need to declare the package in your preamble:


Then you could use this code in order to insert an image in the same path of your file .tex (otherwise you have to specificate the whole path and not only the name of your picture):

 \caption{Ceci n'est pas une pipe - This is not a pipe (Magritte).}
 \label{fig: pipe}

Environment figure options:

  • h - here
  • t - top of the page
  • b - bottom of the page
  • p - extra page
  • ! - force positioning

includegraphics main options:

  • angle=[+/- degree values]
  • scale=[value] (i.e. 0.80 means that you are resizing your picture at the 80%)
  • keepaspectratio=[true/false]

You can refer to a picture in your text by using the \ref{labelcontents}, i.e.:

\ref{fig: pipe}

See also:


Simple tables:

\begin{tabular}{|l|c|r|} % 'l' is for 'left', 'c' is for 'center', 'r' is for 'right'
 first & second & third \\
 1 & 2 & 3 \\

See also:

Math formulas

If you want to obtain some mathematical text without using some special packages directly in your text:

$ e^{i\pi}+1=0 $ 
\begin{math} \vec{F} = m \vec{a}\end{math}
\S = \int{L \: dt} \)
$ \lim_{x \rightarrow \infty} \frac{\sin{x}}{x} = 1 $

… or in a different text block:

\begin{displaymath}e^{i\pi}+1=0 \end{displaymath}
\[\vec{F} = m \vec{a}\]
$$S = \int{L \: dt} $$

… or in a different block of text with the number of the equation flagged:

\begin{equation}\lim_{x \rightarrow \infty} \frac{\sin{x}}{x} = 1 \end{equation}

Some utilities:

See also:


If you want to add some code listings into your text you can use the listings package putting


in your preamble. Then you can define some setting for your code; for instance:


The listings package supports highlighting of all the most common languages and it is highly customizable.

entity eqcomp is
  port (a, b: in bit_vector (3 downto 0);
  eq, neq : out bit);
  end eqcomp;
architecture dataflow of eqcomp is
  signal aux1 : bit;
  neq <= not aux1; -- low active
  aux1 <= ‘1’ when (a = b) else ‘0’;
  eq <= aux1;
 end dataflow;

You can find here the complete list of the supported languages.

See also:

Non-formatted text

Verbatim environment permits to insert large sections of preformated text in a LaTeX file (for example, also symbols like '%', '&', '#' and much more):

Roses are #FF0000 & violets are #0101DF
sugar is sweet and so are you. 


Feynman diagrams

Table of contents

A table of contents (TOC) is automatically created using the command


Note that two consecutive compilation are required to update the table of contents

Other similar commands are \listoftables and \listoffigures which produce a list of tables (LOT) and a list of figures (LOF) respectively.

Supported Languages



\usepackage[italian, english]{babel}

Numerical references

To create references inside your text, use the \cite{refLabel} command wherever you want an external reference to something (books, papers, Web sites, etc.). It is a good practice to use the surname of the first author followed by the last two digits of the year of publication. Each reference will be numbered and each citation will correspond to the number.

Then you can build a bibliography with the LaTex built-in environment thebibliography,

   \bibitem[label]{refKey} Author(s), \emph{Work title}, detailed reference coordinates

Here {n} is the maximum number of expected references in the list, usually {100} works fine. This parameter is mandatory (compile error otherwise).

By default the name of the page will be Bibliography. If you want to change it in References use

\renewcommand{\bibname}{References}  %  print "References" instead of "Bibliography"

Furthermore, by default the bibliography is not automatically added to the table of contents.


Each item of the bibliography is referenced with a number within square brackets. You can assign custom labels to your reference indeed, simply add the [label] option in \bibitem, e.g.

   \bibitem[Krummenacher, 1991]{Krummenacher1991} 
   F. Krummenacher, 
   \emph{Pixel detectors with local intelligence}, 
   NIM A305, 1991, 527-532

As an alternative you can use a BibTex database. See

Harvard referencing

Use the natbib package. Add


in your preamble.

To create references you can use different versions of the basic \cite{} command to display the type of citation you want.

Common options:

  • round round parenthesis ()
  • square square parentheses []

Last update: Serena Panati Nov 6th, 2013

  • vlsi/resources/latex/syntax.txt
  • Ultima modifica: 06/11/2013 23:44
  • da panati