DEV Community

Cover image for How to Install and Use LaTeX
Marcos Oliveira
Marcos Oliveira

Posted on

1

How to Install and Use LaTeX

LaTeX is a high-quality document preparation system, especially used for scientific, technical and mathematical texts. It allows the creation of documents with precise formatting, complex equations, automatic bibliographic references and professional structuring.

LaTeX is an abbreviation of Lamport TeX) was developed in the 1980s by Leslie Lamport. When writing, the writer uses plain text, rather than the formatted text found in WYSIWYG word processors such as Microsoft Word, LibreOffice Writer, and Apple Pages.

The writer uses markup tagging conventions to: define the overall structure of the document (such as an article, book, or letter), to format text throughout a document (such as bold and italics), and to add citations and cross-references.

A TeX typesetting system, such as TeX Live or MiKTeX, is used to produce an output article (electronic publication such as PDF or DVI) suitable for printing or digital distribution. It is also used for the production of personal letters, articles and books on various subjects.

Within the typesetting system, its name is stylized as LaTeX. Currently in the version called: LaTeX 2e.


Installation

In Ubuntu install TeX Live using APT:

sudo apt install texlive-latex-base
Enter fullscreen mode Exit fullscreen mode

If you want a complete installation with fonts and extras, run:

sudo apt install texlive-latex-base texlive-fonts-recommended \
texlive-fonts-extra texlive-latex-extra
Enter fullscreen mode Exit fullscreen mode

This will install almost 1GB of data, so it's not that interesting for beginners.

You can also choose to install the editor TeXstudio (graphical editor for LaTeX):

sudo apt install texstudio
Enter fullscreen mode Exit fullscreen mode

For more information, visit the address: https://www.texstudio.org/.

On Windows:

You can also use WinGet in PowerShell:

winget install -e --id TeXstudio.TeXstudio
Enter fullscreen mode Exit fullscreen mode

Basic example of using LaTeX

Create a file with the extension .tex, for example: file.tex and insert the content below:

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{My First Document}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

\section{Introduction}
Hello, world! This is my first document in LaTeX.

\section{Mathematics}
The quadratic formula is:
\[ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \]

\end{document}
Enter fullscreen mode Exit fullscreen mode

To compile, just use the pdflatex command:

pdflatex file.tex
Enter fullscreen mode Exit fullscreen mode

It may ask you some questions and at the end there will be a question mark: ?, just press ENTER (several times) and it will finish creating the document anyway.

Then just open the file.pdf in your PDF viewer by clicking on it or running it in the terminal:

xdg-open file.pdf
Enter fullscreen mode Exit fullscreen mode

This is in Ubuntu and similar.

It will also generate intermediate files such as: file.aux and file.log, just remove them if you want, next time pdflatex will overwrite them anyway.

rm file.aux file.log
Enter fullscreen mode Exit fullscreen mode

If you are in TeXstudio, press the Compile button (usually a green arrow in TeXstudio):

  • LaTeX will generate a PDF file with the result.

Differences between compilers:

  • PDFLaTeX: Generates PDF directly (recommended for simple texts).
  • LaTeX + DVI: Generates an intermediate file (.dvi) before the PDF.
  • BibTeX: Used to manage bibliographic references.

How to Use LaTeX in Everyday Life?

  • Equations: Use $...$ (inline) or \[...\] (highlight).
  • Tables: Use environments such as tabular.
  • Images: Add with \includegraphics (package graphicx).
  • References: Use \cite{key} and BibTeX for bibliographies.

Useful links


Originally published in: https://terminalroot.com/how-to-install-and-use-latex/

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

πŸ‘‹ Kindness is contagious

DEV is better (more customized, reading settings like dark mode etc) when you're signed in!

Okay