Basic Syntax Create your first LaTeX Title Section Paragraph and Comments Text Processing Fonts Formatting List
Document type in Latex↓
Document Class Document Classes Comparison Document Classes Options
Command Table of Contents Page Numbering Footnotes Language Support
Bibliography ↓
Bibliography Management With Biblatex Bibliography Management With Natbib
Formatting in LaTeX

Formatting & advantages of a proper typesetting
In general it is reffered as format of a document the layout of its pages and more generally the overall style of its text. Behind the scenes numerous typesetting standards operate to ensure readability, and arguably beauty, of a single page.
If the importance of formatting wasn't clear yet, we have some examples below:

Geometry of page
Writing a page doesn't simply mean filling it with text to the brim: each object needs take its own space following determinate criterias, in general each page will have lateral margins and a footer/header space.
The geometry package allows you to alter the layout of certain elements of the page: you can learn more about it in the relative section
There are many pre-made layouts in LaTeX called document classes : you can learn more about document classes in the relative section
Indentation of paragraphs
The indentation of paragraphs is set by the hidden parindent parameter: you can change it (or set to 0) for the whole document by putting the following in your preamble: \setlength\parindent{indentation}. You can instead set the indentation of a specific paragraph to 0 by preceeding it with \noindent
Linewidth and textwidth
It is often necessary to have one element span a certain portion of the page, in this case we can use:
\documentclass[a4paper,12]{article} \usepackage{graphicx} \usepackage{blindtext} \usepackage{mathtools} \begin{document} \twocolumn[%here is still 1 column \centering \huge{TEXT} \par \vspace{-1em} \rule{\widthof{\huge{TEXT}}}{1px} ]{% \blindtext \par\noindent \rule{\linewidth}{1px} \rule{\textwidth}{1px} } \end{document}
Horizontal & textwidth
You can use \hspace{space} and \vspace{space} to respectively add horizontal and vertical spaces in LaTeX, \hfill and \vfill will add a space to fill the current line/column. There are also macros to add fixed spaces, for istance \, is equivalent to \hspace{0.16667em}
\documentclass[a4paper,12]{article} \usepackage{graphicx} \usepackage{blindtext} \usepackage{mathtools} \usepackage{fancyvrb} \DefineShortVerb{\@} \setlength\parindent{0em}%no indentation \begin{document} \section*{HORIZONTAL SPACING} AB A\,B A\;B A\quad B \rule{\widthof{A\quad B}}{1px} A\hspace{5em}B A \hfill B \section*{VERTICAL SPACING} A B C A \vspace{1em} B \vspace{5em} C \vfill D I'm here! \end{document}
The minipage environment
The minipage environment is part of the standard distribution and comes very handy when you need to allign two or more objects: when called it starts a new column of width equal to a fraction of the original page. The syntax is as follows: \begin{minipage}{width}.
To be properly alligned the spacing between minipages must be 0 (you can simply comment it out with %), the first minipage should also be preceeded by a \noindent.
\documentclass[a4paper,12]{article} \usepackage{graphicx} \usepackage{blindtext} \usepackage{mathtools} \begin{document} \noindent\begin{minipage}{0.3333\textwidth} \blindtext \end{minipage} % \begin{minipage}{0.3333\textwidth} \includegraphics[width=\linewidth]{logo_USI.png} \end{minipage}% % \begin{minipage}{0.3333\textwidth} \blindtext \end{minipage} \noindent\blindtext \newpage \begin{minipage}{0.5\textwidth} \includegraphics[width=\linewidth]{logo_USI.png} \end{minipage}% % \begin{minipage}{0.5\textwidth} \blindtext \end{minipage} \end{document}
Float environment
Floats is a generic term used to indicate unbreakeable entities separated from the standard stream of text. When dealing with a float LaTeX will attempt to position it where most conforming with the typesetting standards, while this most often retains good results in some cases it won't be the desidered output.
The following tags can be used to "suggest" where a float should be positioned:
TAG MEANING
h Tries placing the float in the position it was actually declared in the text stream
t Tries placing the float at the top of the page
b Tries placing the float at the bottom of the page
p Will place the float on a separate page with other floats
! Alone will allow LaTeX to ignore some paramethers, such as the total number of floats allowed on a page, in placing the float. When combined with the other tags (ex:h!) it will essentially strengthen them

If the tags are still not enough it's possible to set the absolute position of a flot with the textpos package using the following syntax:\begin{textblock}{blockwidth}[x_block_shift, y_block_shift](x_pos, y_pos) where: Absolute positioning should be your very last resort.
\documentclass[a4paper,12]{article} \usepackage{graphicx} \usepackage{blindtext} \usepackage{mathtools} \usepackage{fancyvrb} \DefineShortVerb{\@} \setlength\parindent{0em}%no indentation \usepackage[absolute,overlay]{textpos} \begin{document} \section*{INLINE FIGURE} \blindtext \includegraphics[width=0.1\linewidth]{logo_USI.png} \blindtext \newpage \section*{FLOATING FIGURE} \blindtext% \begin{figure}\includegraphics[width=0.1\linewidth]{logo_USI.png} \end{figure} \blindtext% \newpage \section*{FLOATING FIGURE WITH "h!" TAG} \blindtext% \begin{figure}[h!]\includegraphics[width=0.1\linewidth]{logo_USI.png} \end{figure} \blindtext% \newpage \section*{FLOATS WITH ABSOLUTE POSITION} \begin{textblock}{3}[0,0](0,0){% \large{This float has a width of 3/16 of the page (the measures are in 16th of the page)and is positioned at the top-left corner} } \end{textblock} \begin{textblock}{3}[1,0](16,0){% \large{This float has a width of 3/16 of the page (the measures are in 16th of the page)and is positioned at the top-right corner. [1,0] is used to shift is anchor point of 1 box width to the left.} } \end{textblock} \begin{textblock}{4}[0,1](0,16){% \large{This float (text +image) has a width of 4/16 of the page (the measures are in 16th of the page)and is positioned at the bottom-left corner. [0,1] is used to shift its anchor point of 1 box width height up. You can also add images such as this one: } \includegraphics[width=0.5\linewidth]{logo_USI.png} } \end{textblock} \begin{textblock}{4}[1.0,1.0](16,16){% \large{This float has a width of 5/16 of the page and is positioned at the bottom-right corner of the page. [1.0,1.0] is used to shift the anchor point of the box of 1 box width and 1 box height from the right corner otherwise it would be completely outside the page.} } \end{textblock} \begin{textblock}{2}[0.5,0.5](8,8){% \large{This float has a width of 3/16 of the page and is positioned at the center of the page} } \end{textblock} \begin{textblock*}{5cm}(100pt,8cm){% \large{With @\begin{textblock*}@ you can use units instead of absolute positions: this block has a width of 5cm, and is distant 100pt/8cm on the x/y axys } } \end{textblock*} \null\newpage %if using only textboxes in a page add \null before \newpage \end{document}
Wrapping floats
It's possible to wrap floats with text by using the package wrapfig, the syntax is as follows:
\begin{wrapfigure}{position_tag}{width} \includegraphics[]{your_figure} \end{wrapfigure}
the vertical spaces can simply be reduced (or added) by using \vspace{space}.
\documentclass[a4paper,12]{article} \usepackage{graphicx} \usepackage{blindtext} \usepackage{wrapfig} \usepackage{caption} \begin{document} \blindtext \begin{wrapfigure}{h}{0.35\linewidth} \vspace{-5pt} \begin{center} \includegraphics[width=0.35\linewidth]{logo_USI.png} \end{center} \vspace{-0pt} %you can use a negative\vspace to reduce the spacing \caption*{WRAPPED FLOAT :)} \vspace{-0pt} %you can use a negative\vspace to reduce the spacing \end{wrapfigure} \blindtext \end{document}