Skip to content

6.1 Fundamentals

1. Latex Fundamentals

LaTeX is a typesetting system used to create high-quality documents, especially those with complex structures, such as mathematical equations, scientific articles, and books. It was built on top of TeX, which was developed by Donald Knuth to give precise control over typesetting.

LaTeX handles the formatting of your document based on the structure you define, so you focus on content, and LaTeX ensures consistency in layout and style. It’s ideal for producing technical and scientific documentation, but it can also be used for creating résumés, presentations, and even books.

1.1 Build LaTeX Files into PDFs

Technically, LaTeX itself does not directly generate PDF files; it generates an intermediate format called DVI (DeVice Independent). However, you can convert LaTeX .tex files into PDFs using the following tools:

  1. pdfLaTeX: This tool directly converts a LaTeX .tex file into a PDF file. It’s the most commonly used method to generate PDFs from LaTeX.

    Example command:

    Terminal window
    pdflatex yourfile.tex
  2. XeLaTeX: A variant of LaTeX that supports Unicode and system fonts. It also directly outputs PDF.

    Example command:

    Terminal window
    xelatex yourfile.tex
  3. LuaLaTeX: Similar to XeLaTeX but with added scripting flexibility via Lua.

    Example command:

    Terminal window
    lualatex yourfile.tex
  4. latexmk: A tool that automates the entire LaTeX compilation process. It can run the required compilation steps (such as multiple passes for bibliography or cross-references) and generate a PDF.

    Example command:

    Terminal window
    latexmk -pdf yourfile.tex

Here’s a breakdown of LaTeX and related tools:

1.2 Latex Tools

1.2.1 LaTeX

  • Definition: LaTeX is a typesetting system used for creating documents, especially those that contain complex mathematical expressions or scientific notations. It builds on TeX (created by Donald Knuth) and provides higher-level commands to format text, structure documents, and include figures, tables, and equations.
  • Use Case: It’s widely used in academia for creating research papers, theses, and books because of its ability to produce high-quality PDFs with precise formatting.

1.2.2 pdfLaTeX

  • Definition: pdfLaTeX is a LaTeX engine that directly generates PDF files from .tex source files, rather than generating a DVI (DeVice Independent) file as traditional LaTeX does.
  • Use Case: It is the most commonly used LaTeX engine, as it outputs PDF files directly. It’s suitable for documents that don’t require complex fonts or Unicode characters and works well for most general purposes.

1.2.3 XeLaTeX

  • Definition: XeLaTeX is an engine that extends LaTeX with better support for Unicode and TrueType/OpenType fonts. It’s based on XeTeX, a modernized version of TeX.
  • Use Case: XeLaTeX is great if you need to work with multiple languages or special fonts, as it allows you to use system-installed fonts (like those in Microsoft Word or on your OS). It’s a good choice for multilingual documents or those that require high-quality typography.

1.2.4 LuaLaTeX

  • Definition: LuaLaTeX is another extended version of LaTeX, integrating Lua scripting. Lua is a lightweight programming language, and LuaLaTeX uses it to enhance LaTeX’s flexibility, allowing users to add more advanced functionality to their documents.
  • Use Case: It’s especially useful when you need to automate aspects of document creation or apply custom typographical rules. LuaLaTeX also supports modern fonts and Unicode, like XeLaTeX, but allows greater customization.

1.2.5 latexmkrc

  • Definition: latexmkrc is a configuration file used by the latexmk tool. latexmk is a Perl script that automatically compiles LaTeX documents by detecting dependencies and running the appropriate compilation commands (e.g., pdflatex, xelatex) multiple times if necessary.
  • Use Case: The latexmkrc file allows you to customize how latexmk runs. For example, you can specify the LaTeX engine to use, set custom compilation options, or automate other tasks related to document building.