YouTip LogoYouTip

Latex Install

LaTeX is a typesetting system based on TeX. Before use, you need to install a TeX distribution and an editor.

\n

This chapter introduces LaTeX installation and configuration, applicable to Windows, macOS, and Linux systems.

\n
\n

LaTeX Installation

\n

1. Windows System

\n

On Windows systems, it is recommended to use MiKTeX or TeX Live to install LaTeX.

\n

Installing MiKTeX

\n
    \n
  1. Download MiKTeX: Visit the MiKTeX official website and download the installer suitable for your system.
  2. \n
  3. Run the Installer: Double-click the downloaded installer and follow the prompts. It is recommended to select "Full Installation" to ensure all common packages are installed.
  4. \n
  5. Configure Environment Variables: After installation, ensure that the MiKTeX bin directory has been added to the system's PATH environment variable. This allows you to use LaTeX commands directly from the command line.
  6. \n
\n

Installing TeX Live

\n
    \n
  1. Download TeX Live: Visit the TeX Live official website and download the installer suitable for your system.
  2. \n
  3. Run the Installer: Double-click the downloaded installer and follow the prompts. The TeX Live installation process can be time-consuming as it includes a large number of packages and tools.
  4. \n
  5. Configure Environment Variables: After installation, ensure that the TeX Live bin directory has been added to the system's PATH environment variable.
  6. \n
\n

2. macOS System

\n

On macOS systems, it is recommended to use MacTeX to install LaTeX.

\n

Installing MacTeX

\n
    \n
  1. Download MacTeX: Visit the MacTeX official website and download the installer suitable for your system.
  2. \n
  3. Run the Installer: Double-click the downloaded .pkg file and follow the prompts. MacTeX includes TeX Live along with related GUI tools.
  4. \n
  5. Configure Environment Variables: After installation, ensure that the TeX Live bin directory has been added to the system's PATH environment variable.
  6. \n
\n

3. Linux System

\n

On Linux systems, it is recommended to use TeX Live to install LaTeX.

\n

3.3.1 Installing TeX Live

\n
    \n
  1. Install using Package Manager: Most Linux distributions provide TeX Live packages. You can use your package manager to install it. For example, on Ubuntu, you can use the following command: sudo apt-get install texlive-full. This will install the complete TeX Live distribution, including all common packages and tools.
  2. \n
  3. Manual Installation: If you need the latest version of TeX Live, you can download the installation script from the TeX Live official website and install it manually.
  4. \n
\n
\n

LaTeX Configuration

\n

Editor Selection

\n

LaTeX documents are plain text files, so you can use any text editor to write LaTeX code. However, using a dedicated LaTeX editor can improve efficiency. Here are some commonly used LaTeX editors:

\n
    \n
  • TeXstudio: A cross-platform LaTeX editor with powerful features, suitable for both beginners and advanced users.
  • \n
  • Overleaf: An online LaTeX editor that requires no installation, ideal for collaboration and quick editing.
  • \n
  • VS Code: A general-purpose code editor that supports LaTeX editing and compilation through plugins (such as LaTeX Workshop).
  • \n
\n

Compiling LaTeX Documents

\n

LaTeX documents need to be compiled to generate the final PDF file. Common compilation commands include:

\n
    \n
  • pdflatex: Generates a PDF file, suitable for most documents.
  • \n
  • xelatex: Supports Unicode and TrueType fonts, suitable for processing Chinese documents.
  • \n
  • lualatex: A Lua-based compilation engine that supports modern fonts and advanced features.
  • \n
\n

The usage of compilation commands is as follows:

\n
pdflatex mydocument.tex
\n

This will generate the mydocument.pdf file.

\n

Handling Chinese Documents

\n

If you need to handle Chinese documents, it is recommended to use the xelatex or lualatex compilation engines, along with the ctex package. Below is a simple LaTeX Chinese document example:

\n

Example

\n
\\documentclass{ctexart}\n\\begin{document}\n  Hello, world!\n\\end{document}
\n

To compile this document using xelatex:

\n

Example

\n
xelatex mydocument.tex
\n

Installing and Managing Packages

\n

LaTeX packages can be installed and managed via a package manager. In MiKTeX and TeX Live, you can use the following commands to install packages:

\n
    \n
  • MiKTeX: Use MiKTeX Console to search for and install packages.
  • \n
  • TeX Live: Use the tlmgr command to install packages. For example: tlmgr install <package-name>
  • \n
← Nextjs Components LayoutLatex Tutorial β†’