Register | Login | Visitors: 184 / 24 h

First Document

Creating File

Before we can add our content, we have to create an empty file with any arbitrary name, for instance, "first.tex". The important part is the ending which has to be .tex. If you use Texmaker, you can click on "New Document" and then save the document with your desired file name. You are now able to add text to your file. It is further important to know that commands in LaTeX are starting with a backslash. Usually, a command is followed by curly brackets in the form {}. Inside the brackets, you can add an argument if the command allows that. Some commands require even more than one argument. In this case, you have to add more brackets {} including the argument behind that.

Adding Content

We always start a LaTeX document with with the command \documentclass, which takes exactly one argument, in the following way:
\documentclass{article}
to define the document class we want to use. In this case, it is "article". Later we will also come to know about other document classes such as "report" or "book". In order to compile a LaTeX document, we have to tell the interpreter where the document starts and where it ends. For that purpose, we have to add the environment document in the following way:
\begin{document}
\end{document}
If we compile our document now, we will receive an error message. This happens because LaTeX does not allow the creation of empty documents without any content. Therefore, we will add the line Hello World! between these two inserted lines. Our first full documents look now as follows:
\documentclass{article}

\begin{document}
Hellow World!
\end{document}
When we compile this code we can empty the page with the page number at the bottom and the text "Hello World!" in the first line.
Our first document containing the text Our first document containing the text "Hello World!"

Adding Packages

The functionality of LaTeX is very limited. For that purpose, you have the possibility to insert further packages with the command \usepackage{}. The space within the brackets is reserved for the package name. Packages are always to be inserted into the preamble which is the place between the definition of the document class and \begin{document}. One of the easiest packages is called "blindtext" which we will use now for testing purposes using the command
\usepackage{blindtext}
It includes the command \blindtext that you can use within your text to create a simple blind text that is commonly used to test the layout of a document. You can now adjust your file according to the following code to see the outcome:
\documentclass{article}

\usepackage{blindtext}

\begin{document}
\blindtext
\end{document}
This page contains 540 words and 3261 characters.