In this post, we are going to write our first latex code.

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}

\usepackage[spanish]{babel}

\title{My first document}

\author{Myself}

\date{\today}

\begin{document}

\maketitle

Hello world!

We can write \textbf{bold} or \emph{italics} words and sentences.

\end{document}

We are going to analyze line by line the previous code.

\documentclass[a4paper,12pt]{article} This line indicates three aspects: the document format is A4 size, the font size is 12 points, and the structure of the document follows the article standard format. There are many other formats like the book, the slides, the diptych, etc.

\usepackage[utf8]{inputenc} This line shows the code we use to save the file in tex format. The format depends on the operating system and the editor used. It is important because depending on the chosen format, we could open (or not) in other editors. If you have problems, you can replaceutf8 by latin1, ansinew (windows), cp850 (windows, dos), or applemac (mac).

\usepackage[T1]{fontenc} This line shows the coding to be used to generate the output file (usually pdf). The option T1 can generate most existing symbols and accents in Western European languages (Spanish, French, German, etc.).

\usepackage[spanish]{babel} This line sets up the document in Spanish format, so the rules of Spanish writing that the document will follow. Examples are the use of the comma to represent decimal numbers, the structure of dates, or use double quotes instead of single quotes.

\title{My first document} The function \title{} defines the document title. This information will be stored in the metadata of the final document.

\author{Myself} The function \author{} defines the author(s) of the document. This information will be stored in the metadata of the final document.

\date{\today} The function \date{} defines the document date. This information will be stored in the metadata of the final document. Here we can indicate a specific date or use the function \today which generates the current date of the compilation of the document.

\begin{document} So far, we have been setting up our document and defining metadata of the final document. This line indicates the beginning of the contents of the document.

\maketitle The function \maketitle generates the standard header (title, author and date) of an article from the metadata of the document.

Hello word!! We can write \textbf{bold} or \emph{italics} words and sentences. From here, we start writing the document text. The function \textbf{} lets you write words and phrases in bold, and the function \emph{} lets you write words and phrases in italics.

\end{document} This line indicates the end of the content of the document.

Now we just need to complicate the document and get the final document (in pdf format).

Hope you find it useful.