Table of Contents#
- Prerequisites
- LaTeX Compilers on Ubuntu 20.04
- LaTeX Editors on Ubuntu 20.04
- How to Compile a LaTeX Document on Ubuntu 20.04
- Conclusion
- References
Prerequisites#
Before installing LaTeX tools, ensure your Ubuntu 20.04 system is up-to-date:
sudo apt update && sudo apt upgrade -yYou’ll also need sudo privileges to install packages.
LaTeX Compilers on Ubuntu 20.04#
A LaTeX compiler converts your .tex source code into a readable format (e.g., PDF). Ubuntu 20.04 supports two primary compiler distributions: TeX Live (most common) and MiKTeX (less common on Linux but available).
1. TeX Live#
TeX Live is the gold standard for LaTeX on Linux. It includes all major LaTeX engines, packages, and utilities.
Installation#
Ubuntu 20.04’s default repositories include TeX Live. Install the full distribution (recommended for most users) with:
sudo apt install texlive-full -yNote: texlive-full is large (~6 GB) but includes all packages. For a minimal installation (basic tools only), use:
sudo apt install texlive-base texlive-latex-recommended -yTo install additional packages later (e.g., for fonts or languages), use:
sudo apt install texlive-fonts-extra texlive-lang-english # Example: extra fonts + English supportKey Features#
- Includes engines:
pdfLaTeX,XeLaTeX,LuaLaTeX, andLaTeX(DVI output). - Pre-installed with thousands of packages (e.g.,
amsmath,graphicx). - Regular updates via Ubuntu’s package manager.
2. MiKTeX (Linux Version)#
MiKTeX is a lightweight, Windows-centric LaTeX distribution, but it offers a Linux port. It differs from TeX Live by installing packages on-demand (useful for limited disk space).
Installation#
MiKTeX isn’t in Ubuntu’s default repos. Use the official PPA:
# Add MiKTeX GPG key
wget -qO - https://miktex.org/download/keyring.gpg | sudo tee /usr/share/keyrings/miktex-keyring.asc > /dev/null
# Add MiKTeX repository
echo "deb [signed-by=/usr/share/keyrings/miktex-keyring.asc] https://miktex.org/download/ubuntu focal universe" | sudo tee /etc/apt/sources.list.d/miktex.list > /dev/null
# Install MiKTeX
sudo apt update && sudo apt install miktex -y
# Complete setup (run as regular user)
miktexsetup finishKey Features#
- On-demand package installation (reduces initial disk usage).
- GUI and command-line package managers.
- Less common on Linux; may have compatibility issues with some Ubuntu tools.
3. LaTeX Engines: pdfLaTeX, XeLaTeX, LuaLaTeX#
TeX Live and MiKTeX include engines to compile .tex files. Here’s when to use each:
| Engine | Use Case | Advantages |
|---|---|---|
pdfLaTeX | Standard documents (PDF output) | Fast, widely compatible. |
XeLaTeX | Advanced font support (TrueType/OpenType) | Better handling of system fonts (e.g., Arial). |
LuaLaTeX | Dynamic documents (Lua scripting) | Extensible with Lua; supports modern fonts. |
LaTeX Editors on Ubuntu 20.04#
Editors provide a user-friendly interface to write, edit, and preview LaTeX code. We’ll cover GUI editors (best for beginners) and terminal/IDE-based tools (for advanced users).
GUI Editors#
These tools offer point-and-click interfaces, live previews, and built-in compilation.
TeXmaker#
TeXmaker is a lightweight, cross-platform LaTeX editor with a clean interface. It’s ideal for beginners and casual users.
Installation#
TeXmaker is in Ubuntu’s repos:
sudo apt install texmaker -yKey Features#
- Live PDF preview (synchronized with code).
- Auto-completion for LaTeX commands.
- Built-in spell checker and syntax highlighting.
- Support for
pdfLaTeX,XeLaTeX, andLuaLaTeX.
Pros/Cons#
- Pros: Lightweight, fast, no bloatware.
- Cons: Fewer advanced features than TeXstudio.
TeXstudio#
TeXstudio is a fork of TeXmaker with enhanced features (e.g., better auto-completion, debugging tools). It’s widely regarded as the best GUI editor for LaTeX.
Installation#
TeXstudio is in Ubuntu’s universe repo (enabled by default on most systems):
sudo apt install texstudio -yKey Features#
- Intelligent auto-completion (suggests commands, labels, and references).
- Built-in PDF viewer with forward/backward search (click PDF to jump to code).
- Syntax checking and error highlighting.
- Customizable keyboard shortcuts.
Pros/Cons#
- Pros: Feature-rich, beginner-friendly, active development.
- Cons: Slightly heavier than TeXmaker (~100 MB vs. 50 MB).
Kile#
Kile is a KDE-integrated LaTeX editor, perfect if you use the KDE desktop environment (e.g., Kubuntu).
Installation#
sudo apt install kile -yKey Features#
- Tight integration with KDE (uses KDE themes, file managers).
- Project management tools (organize multi-file documents).
- LaTeX wizard for generating templates (e.g., articles, theses).
Pros/Cons#
- Pros: Great for KDE users, robust project support.
- Cons: Less polished on non-KDE desktops (e.g., GNOME).
LyX#
LyX is a “WYSIWYM” (What You See Is What You Mean) editor. Instead of writing raw LaTeX, you edit a visual document, and LyX generates LaTeX code in the background.
Installation#
sudo apt install lyx -yKey Features#
- Visual editing (no need to memorize LaTeX commands).
- Drag-and-drop equation editing.
- Export to PDF, HTML, and Office formats.
Pros/Cons#
- Pros: Best for LaTeX beginners, intuitive for non-technical users.
- Cons: Limits control over raw LaTeX code (can be disabled).
Gummi#
Gummi is a minimalist editor focused on live preview. It’s ideal for quick document drafting.
Installation#
Gummi is in Ubuntu’s repos:
sudo apt install gummi -yKey Features#
- Instant live preview (updates as you type).
- Distraction-free mode (hides toolbars).
- Lightweight (~20 MB).
Pros/Cons#
- Pros: Fast, simple, great for short documents.
- Cons: Lacks advanced features (e.g., project management).
Overleaf (Web-Based)#
Overleaf is a cloud-based LaTeX editor (no installation needed). It’s perfect for collaboration (share documents with others in real time).
Usage#
Access Overleaf via your browser: overleaf.com. Free accounts include basic features; paid plans add more storage and collaboration tools.
Key Features#
- Real-time collaboration (like Google Docs for LaTeX).
- Template gallery (e.g., IEEE papers, Beamer presentations).
- Automatic backups and version history.
Pros/Cons#
- Pros: No setup required, excellent for teamwork.
- Cons: Requires internet, limited offline access.
Terminal/IDE-Based Editors#
These tools are for users comfortable with the terminal or code editors like VS Code.
Emacs with AUCTeX#
Emacs is a powerful text editor; when paired with the AUCTeX package, it becomes a full-featured LaTeX IDE.
Installation#
sudo apt install emacs auctex -yKey Features#
- Advanced code folding (collapse sections, environments).
- Interactive debugging (jump to errors with
C-c). - Support for multi-file projects and BibTeX (citations).
Pros/Cons#
- Pros: Extremely customizable (via Emacs Lisp).
- Cons: Steep learning curve for new Emacs users.
Vim with vim-latex#
Vim users can add LaTeX support with the vim-latex plugin (also called latex-suite).
Installation#
- Install Vim:
sudo apt install vim -y - Install
vim-latexvia Vim’s package manager (e.g.,vim-plug):- Add to
~/.vimrc:call plug#begin() Plug 'lervag/vim-latex' call plug#end() - Run
:PlugInstallin Vim.
- Add to
Key Features#
- Command abbreviations (e.g.,
iiexpands to\item). - PDF preview via
:LLPStartPreview. - Integration with
pdflatexandBibTeX.
Pros/Cons#
- Pros: Fast, keyboard-driven workflow for Vim enthusiasts.
- Cons: Requires Vim proficiency; setup is non-trivial.
VS Code with LaTeX Workshop#
VS Code, a popular IDE, can be transformed into a LaTeX editor with the LaTeX Workshop extension.
Installation#
- Install VS Code:
sudo snap install code --classic # Or use .deb from Microsoft’s site - Open VS Code → Extensions → Search for “LaTeX Workshop” → Install.
Key Features#
- Live PDF preview with sync (click code to jump to PDF).
- IntelliSense for LaTeX commands.
- Build automation (configurable via
settings.json).
Pros/Cons#
- Pros: Familiar interface for VS Code users, rich ecosystem.
- Cons: Heavier than dedicated LaTeX editors.
How to Compile a LaTeX Document on Ubuntu 20.04#
Once you’ve installed an editor and TeX Live, here’s how to compile a simple document:
-
Write a
.texfile (e.g.,document.tex):\documentclass{article} \title{My First LaTeX Document} \author{John Doe} \date{\today} \begin{document} \maketitle Hello, \LaTeX! \end{document} -
Compile with pdfLaTeX (via terminal or editor):
- Terminal:
pdflatex document.tex # Generates document.pdf - GUI editors: Click “Build” or “Compile” (e.g., F5 in TeXstudio).
- Terminal:
Conclusion#
Ubuntu 20.04 offers a wealth of LaTeX tools for every workflow:
- Beginners: Start with TeXstudio (feature-rich, easy) or LyX (visual editing).
- KDE Users: Use Kile for seamless desktop integration.
- Advanced Users: Try Emacs+AUCTeX (customizable) or VS Code+LaTeX Workshop (modern IDE).
- Collaboration: Use Overleaf (cloud-based, real-time editing).
Pair any editor with TeX Live (the default compiler) for the best experience.