How to install LaTex on Ubuntu 18.04 Bionic Beaver Linux

Objective

The objective of this article is to provide reader with instructions on how to install LaTeX on Ubuntu 18.04.

Furthermore, this article will also explain the procedure on how to compile a basic Latex document from a command line. Lastly, the reader will be introduced to some of the best LaTeX editors available on the Ubuntu 18.04 system.

Operating System and Software Versions

  • Operating System: – Ubuntu 18.04 Bionic Beaver Linux

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Conventions

  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)

Instructions

LaTeX Installation on Ubuntu

Ubuntu repository consist of various meta packages from which each targets different type of a LaTeX user. Below you can find the most common installation packages for LaTeX and their approximate disk space requirements based on Ubuntu 18.04 with minimal installation selected:

  • texlive-base – 136 MB
  • texlive-latex-recommended – 177 MB
  • texlive – 240 MB
  • texlive-latex-extra – 404 MB
  • texlive-full – 4714 MB

The first package texlive-base will install just the basics to get you started with LaTeX. texlive or texlive-latex-extra is most likely the best way to get started for most users.

However, our package selection is only motivated by the requirement for the least disk space consumed after the LaTeX installation. If you have plenty of space and a good download speed nothing stops you to go for texlive-full package. But be aware that this package will fetch the whole lot, including, but not limited to, eg. Japanese language pack.

Furthermore, Ubuntu offers more profession targeted package selections such as:

  • texlive-publishers
  • texlive-science
  • texlive-pstricks
  • texlive-pictures

Regardless of your package choice you can install LaTeX by use of the apt command. The following linux command will install the LaTeX package: texlive-latex-extra. Replace the package name with the one you wish to install, open up terminal and enter:

$ sudo apt install texlive-latex-extra

That is all.



Compile LaTeX “Hello World”

Now, that we have LaTeX installed let’s just confirm the installation by compling a simple LaTeX code.

Open up any text editor like for example gedit, enter the following code and save as hello-world.tex:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
Hello world \LaTeX

\url{https://linuxconfig.org}
\end{document}

Once you have the above LaTeX code saved use the pdflatex command to compile it to PDF. If the pdflatex command is available on your system you will need to install texlive-extra-utils before you can use it:

$ pdflatex hello-world.tex

The above command will compile your hello-world.tex to hello-world.pdf. Next, start Evince PDF viewer to see the result:

$ evince hello-world.pdf
Compile LaTeX to PDF from command line on Ubuntu 18.04.

Compile LaTeX to PDF from command line on Ubuntu 18.04.


List of LaTeX editors

The following section will provide you with a list of some of the best LaTeX editors on Ubuntu 18.04 system.

gedit - with LaTeX plugin support on Ubuntu 18.04

Gedit with LaTeX plugin enabled. Gedit is most likely already available on your system. However, to get LaTeX support you need to install the LaTeX plugin via gedit-latex-plugin package.

$ sudo apt install gedit-latex-plugin

Once the package is installed navigate to Preferences-->Plugins and enable the LaTeX plugin.

Lyx - later editor and compiler on Ubuntu 18.04

LyX is more sophisticated and dedicated LaTeX editor with a great documentation to get you started in no time.

$ sudo apt install lyx
Kile - KDE based LaTeX editor on Ubuntu 18.04

Kile is a robust LaTeX editor. It is based on Qt and hence the installation on non-plasma KDE desktop will require more disk space. However, it is surely worth every byte of your disk space.

$ sudo apt install kile
TeXstudio LaTeX editor on Ubuntu 18.04

TeXstudio LaTeX editor is also a solid choice. It is feature rich with great neat interface.

$ sudo apt install texstudio


ALTTEXT

Yet another LaTeX editor and compiler is Texmaker.

$ sudo apt install texmaker
Gummi LaTeX editor on Ubuntu 18.04

Lastly, you may opt-in for Gummi LaTeX editor and compiler. The nice default feature on Gummi is auto-compilation of the LaTeX code to the right hand side document preview.

$ sudo apt install gummi