Getting Started

How to Install LaTeX on Ubuntu with TeX Live

Install LaTeX on Ubuntu with TeX Live using apt, choose the right texlive packages, verify pdflatex, add an editor, and fix common missing-package errors.

On this page
  1. Quick answer
  2. Choose a package set
  3. Install TeX Live with apt
  4. Check the install
  5. Compile a test document
  6. Install an editor
  7. Versions: apt or the TUG installer
  8. Add missing packages
  9. Updating
  10. Troubleshooting
  11. Next steps

Quick answer

Update your package list, then install TeX Live and the extra LaTeX packages from apt:

sudo apt update
sudo apt install texlive texlive-latex-extra

When the install finishes, run pdflatex --version to confirm it works. The rest of this guide covers choosing a package set, testing a document, adding an editor, and fixing missing packages.

Choose a package set

Ubuntu splits TeX Live into several packages. Choose the set that matches how much you want installed up front:

Package What it adds When to choose it
texlive The core TeX Live engines and base LaTeX packages A minimal base. You add other packages as needed.
texlive-latex-extra Many widely used extra LaTeX packages Recommended for most users
texlive-full Nearly everything in the apt TeX Live set You want to avoid most missing-package errors. It takes several gigabytes.

Most people should install texlive and texlive-latex-extra. Use texlive-full only if you expect to need many specialized packages.

Install TeX Live with apt

Run these commands in a terminal:

sudo apt update
sudo apt install texlive texlive-latex-extra

The install can take a while, depending on your connection and the package set you chose. If you want a build tool that runs the engine as many times as needed, install latexmk too:

sudo apt install latexmk

Check the install

Run:

pdflatex --version

You should see a line for pdfTeX and its TeX Live version. If the command is not found, the install did not finish. Run the apt install command again and check for errors in its output.

Compile a test document

Create a file named hello.tex with this content:

\documentclass{article}
\begin{document}
Hello, \LaTeX!
\end{document}

Compile it from the same folder:

pdflatex hello.tex

This creates hello.pdf. Open it with the default viewer:

xdg-open hello.pdf

If the PDF opens and shows “Hello, LaTeX!”, your setup works.

Install an editor

You can write .tex files in any text editor, but a LaTeX editor shows errors and builds the PDF for you. Three common choices:

  • TeXstudio: sudo apt install texstudio
  • Texmaker: sudo apt install texmaker
  • VS Code with the LaTeX Workshop extension: install VS Code from Microsoft’s website, then add LaTeX Workshop from the Extensions panel. The extension uses the TeX Live tools you just installed.

For a fuller comparison, see which software is best for LaTeX.

Versions: apt or the TUG installer

The apt version of TeX Live is a snapshot that matches your Ubuntu release. It can be older than the latest TeX Live release. For most documents, that doesn’t matter. If you need the newest TeX Live, the TeX Users Group (TUG) publishes its own Linux installer at tug.org/texlive. That install goes into its own location and is updated with tlmgr, not apt. Don’t mix the two installs without reading their documentation, because the programs can conflict.

Add missing packages

If a document needs a package that isn’t installed, search for the file that’s missing:

sudo apt install apt-file
sudo apt-file update
apt-file search mypackage.sty

Install the package that apt-file reports. For more options, including putting a .sty file in your project folder, see how to install LaTeX packages.

Updating

Ubuntu updates apt-installed TeX Live along with the rest of the system:

sudo apt update
sudo apt upgrade

Troubleshooting

  • pdflatex: command not found. The install may have failed. Run sudo apt install texlive again and check the output for errors.
  • A document reports a missing .sty file. Use apt-file search as shown above, or install texlive-full if you expect many packages.
  • pdflatex --version shows a version you don’t expect. You may have two installs. Run which -a pdflatex to list every copy on your system, and use the one you intend.
  • Your document fails to compile. Read the first error in the log. The getting started guide explains the most common messages.

Next steps

The complete guide to getting started

Getting Started with LaTeX: Document Preparation, Editors and Workflow
Read the guide

Keep exploring

Guides from other topics

All topics →