A primer to your first document: The sheet and Language

latexteada

latexteada

Posted on January 16, 2021

A primer to your first document: The sheet and Language

Hello everyone :)

As I have uttered in this post, I am going to start with the very basics, this is, How to configure the sheet where I will be working and some basics commands

documentclass Command

Do you remember that in this article I told you about the arguments, well welcome to your first command with both of them

\documentclass[optional]{typeOfDocument}
Enter fullscreen mode Exit fullscreen mode

This is the first command that you need to put in your document, there you configure the type of document, as follows:

  • In [optional] you put the size of the paper and the font size, some of them are

    • Size of paper: a4paper, a5paper, letterpaper (default), legalpaper
    • Font size: 10pt, 11pt, 12pt. We can add more sizes but we need to import other stuff, we are going to work with these fonts sizes
  • In {typeOfDocument} you put the type of document you are going to work with, these can be article, book, beamer, etc.

    • There are more types of documents, but we are going to be focused on these

So

\documentclass[12pt, a4paper]{article}
Enter fullscreen mode Exit fullscreen mode

Is an article with paper size a4paper and the font size 12pt

Everything is going well, we just have configured the most important thing, the font size and the type of document. Now let's configure our working area, it is, the margins, but before that, we need to explain something important

Packages

A package is a bunch of code, that is in a file, which adds features to our document. The packages must be in the preamble. We can add a package to our document with

\usepackage{nameOfThePackage}
Enter fullscreen mode Exit fullscreen mode

The geometry package

We modify the dimensions of our working area with this package

\usepackage[dimensions]{geometry}
Enter fullscreen mode Exit fullscreen mode

In [dimensions] we set the margins, we can use

  • pt: point, mm: millimeter, cm: centimeter, in: inch

So

\usepackage[left=2cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}
Enter fullscreen mode Exit fullscreen mode

It's a document with a left margin of 2cm, and the right, top, and bottom margin of 1.5cm

Ok ok, we have set the type of paper, font size, and the margins, everything is ready to start writing.

Language

The default language is English

If we want to write in another language we must import some packages

inputenc package

Allows us to specify a specific input encoding

\usepackage[typeOfEncoding]{inputenc}
Enter fullscreen mode Exit fullscreen mode
  • For Spanish, German and Russian we use utf8

fontenc package

Allows us to select font encodings, this is, the special characters used in the different languages

\usepackage[typeOfEncoding]{fontenc}
Enter fullscreen mode Exit fullscreen mode
  • German: T1, Russian: T2A

babel package

Allows us to use special characters of the language and also translates some elements, predetermined ones, in the document

\usepackage[language]{babel}
Enter fullscreen mode Exit fullscreen mode

Where in language we put the name of the language.

  • German: ngerman, Russian: russian, Spanish: spanish

Multiple languages

What happens if we use more than one language in the document where we are working. Well, we just add all the languages that we are using separated by commas

\usepackage[l1,...,ln]{babel} 
Enter fullscreen mode Exit fullscreen mode

Prefered Language

The babel package, as we have checked, translate into another language some elements, the predetermined ones. If we are using multiple languages and we want the titles of sections or predefined words were translated into the language we want we just need to put main=language to that language that we want

\usepackage[main=l1,...,ln]{babel} 
Enter fullscreen mode Exit fullscreen mode
  • Of course, this will happen if we have set the current encoding types in fontenc and inputenc. If we have not set these, we will get an error or the titles will not be translated into the language desired

An Example

blog

This is a document of type article with font-size 12pt and size of paper letterpaper. Its margins are left=2cm, right=1.5cm, top=1.5cm, bottom=1.5cm, the author will write on a utf8 encoding and will use the Russian language because the T2A package was imported. The document has the Russian language as the first language, this is, all the titles will appear in Russian. The body of the text is Hello, do not forget to follow me in @latexteada.
Спасибо - gracias en Ruso (Texto en Español)

Just compile it, if you do not remember you can revise it here. Do not cry of happiness, this is your second LaTeX document

Thanks, do not forget that you can comment on how was your experience or share something.

See you :)

💖 💪 🙅 🚩
latexteada
latexteada

Posted on January 16, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related