DEV Community

latexteada
latexteada

Posted on

Kicking off with LaTeX: Installation

This probably is the first time you face LaTeX. Do not worry I am going to introduce you to this realm, so attire for this special occasion
There is a chance that your OS has installed LaTeX, so observe because here is how you are going to trap that:

Do I have LaTeX on my pc?

If you use Linux / iOs just write in the terminal

pdflatex --version

If you have installed any distribution of LaTeX it will appear something like this Remember that the version can change, it depends on when you are reading and doing this
Checking

  • If you use Windows and you have not installed anything about LaTeX then you do not have anything related to LaTeX on your PC

Note: To create LaTeX documents you need to have installed the compiler, if you just want to try it you can do it online

Overleaf

This is a LaTeX online editor that you can try here Overleaf, you just need to create your account and start editing, you do not need to install anything on your pc

  • If you have chosen overleaf instead of installing

Welcome to the virtual world of LaTeX :)

Installing LaTeX

If you already have installed LaTeX you can skip this section :)

Installing the compiler

  • If you use Linux type the following in the terminal
    sudo apt install texlive-latex-extra

  • If you use Mac go to this link and download MacTeX.pkg and then install it like any other program

  • If you use Windows go to this link, download the Installer and install it like any other program

Installing the TeX editor

Well, you have installed the compiler, now

where can you write your first document?

I do really suggest you an editor which autocomplete the commands because You are going to save a lot of time, this is, you just are going to write a few letters of the command instead of the entire command and the editor is going to autocomplete the command.

My best suggestion is to install Visual Studio Code

I have tried at least 5 different text editors, the disadvantage of the others is that those do not have the autocompletion for all the commands, just the most common ones, so if you are going to create a new command the editor won't autocomplete that command.

You can download Visual Studio Code in this link you just download it like any other program. Once you downloaded VSCode follow these steps to install the LaTeX extension

  1. Type Ctrl + Shift + X to open the extensions menu, Or you can click there extension
  2. Search LaTeX and select the LaTeX Workshop extension LaTeXExtension
  3. Install the extension by clicking on the blue option install

Congratulations you have set up everything you need to write your first LaTeX document

Writing your first (or second) LaTeX document

I suggest you: Create a unique directory for each LaTeX document because when you compile your document some other files are going to be created so to avoid a mess it is better to create a new directory for that project

  1. Create a folder anywhere you want
  2. Create a new file, in VSCode just type Ctrl + n
    • We need that VSCode knows in which language we are typing to turn on the autocomplete option if we do not tell it in which language we are writing VSCode thinks that it is just plain text
  3. Let's save the file, just type Ctrl + s and be sure that you save with a .tex extension in the directory you created in step 1Name
    • Did you notice? There is a new icon in VSCodeIcon Yes, this means now you are writing LaTeX
  4. Let's create the document. LaTeX instruction's indicator is a backslash \, just type the followingThedocument

Congratulations you have typed your first LaTeX document

Compiling your LaTeX document

  • Remember that you have edited this document, this is, there is new stuff, you can know that you have edited the document because there is a white dot in the current documentdot To save the changes just type again Ctrl + s

If you are using VSCode

There is a green Play icon at the right top
icon

  • This icon is only available once you have saved your file, if you do not have the icon, save your file with the .tex extension

When you click on that icon the document will be compiled.

  • You can see that it is compiling because at the left bottom there is an indicator of that. We will know that the document is compiled when this icon appearspalomita

To visualize your document

  1. Go to the LaTeX extension that you already installed
  2. Select the option View LaTeX PDF
  3. Click on the best option for you. view

I suggest you the option View in web browser because if you are surfing the internet, listening to music, or reading something while you are typing LaTeX you will have the LaTeX document in the same place

  • Note: That is to visualize the document while you are editing it, so, each time you save the changes you did it will actualize automatically, you do not need to click on the option view document each time you change something.

When you clicked on the green button some files were created in the directory that you just created, to see those just go to that folder, there will be a folder called build
files

Inside build there will be the files generated

Bingo! there is the generated file in .pdf format, do not pay attention to the other files, just focus on the .pdf file, open it and that is what you just created :)

Please do not cry of happiness

Compiling in terminal

If you do not use VSCode or for any reason you want to compile the code in the terminal

  1. Open the terminal and go to the directory where your file is, of course, your .tex file that you have createdcompter
    • Remember that if you want to compile in the terminal you do not need to have installed VSCode, but you do need to have installed the compiler
  2. To compile write pdflatex nameOfYourFile.tex where nameOfYourFile is the name of your file and do not forget the extension. message
    • This means your file is compiled
  3. Go to your directory and check that there are new filestermcomp

Open the .pdf file, that is what you just created :)

Please do not cry of happiness

That is all mates, if you have any question, suggestion, or something you want to share please comment

Follow me on Twitter @latexteada

Because sometimes I will be publishing some stuff there

Greetings

Top comments (0)