# LaTeX engines & packages

Choose Tectonic or a latexmk compiler, use an existing TeX distribution, or install Oleafly's managed TinyTeX.

Oleafly ships Tectonic and can also compile through `latexmk`. The project compiler menu controls day-to-day builds. **Settings → Engines** shows the TeX distributions and packages available on your machine.

## Tectonic: the everyday engine

**Tectonic** is the default. It needs no separate installation, fetches packages as needed, and caches them for offline use. It is a good fit for most projects and remains available even when no system TeX distribution is installed.

For **tagged PDFs**, use the LuaLaTeX workflow. Tags describe document structure for assistive technology. Inspect the result with Preflight after compiling.

## latexmk and system TeX

Choose pdfLaTeX, XeLaTeX, or LuaLaTeX from a project's compiler menu when the project depends on a traditional TeX Live or MiKTeX workflow. Oleafly runs those compilers through `latexmk`.

There are two ways to provide that toolchain:

1. **Use an existing installation.** Oleafly detects MacTeX, TeX Live, MiKTeX, and TinyTeX on your system. A system installation takes priority over Oleafly's managed copy only when its binary directory contains `latexmk`, pdfLaTeX, XeLaTeX, LuaLaTeX, `kpsewhich`, and Biber. A partial installation cannot silently outrank a working managed TinyTeX.
2. **Install managed TinyTeX.** The download is about 250 MB and installs under `~/.oleafly/tinytex` with no administrator access. You can remove it from Settings later.

`latexmk` is not a filesystem sandbox. Even with shell commands blocked, TeX can read files available to your account. Oleafly also disables project, user, and system `.latexmkrc` files because they are executable Perl. Use system TeX only for projects you trust. Imported projects stay on Tectonic until you choose a system compiler.

With an engine present, the [Preflight](/docs/preflight/) panel's **Compile tagged and verify** button can produce a tagged PDF with LuaLaTeX and immediately audit it, in one step. Prefer your own toolchain? Preflight's **Prepare for accessible export** rewrites your source for tagging and you compile it with any LuaLaTeX (TeX Live 2025 or newer) outside the app.

## The package manager

Below the engine status sits a filterable **Packages** list for the LuaLaTeX side, powered by `tlmgr`:

- Start with the suggested package list, or enter at least two characters and choose **Search TeX Live** to query the full catalog.
- Search by a package name or a file it contains. Oleafly shows the owning TeX Live package when those names differ.
- **Add** or **Remove** a package with one click. Installed rows show whether the package is in the system tree, your personal tree, or both.
- Check the tagging badge before an accessible export: **tagging: caution** marks packages that can reduce tag quality, while **breaks tagging** marks known conflicts.

This package manager applies to TeX Live and TinyTeX distributions used by `latexmk`. Tectonic manages its own package cache. For MiKTeX, use MiKTeX Console.

### Recover from a missing file

A package is not always named after the file mentioned in a compile log. For example, `tikz.sty` is installed by the `pgf` package. Installing a guessed package called `tikz` would fail.

When a `latexmk` compile reports a missing file, use **Find and install** in the message. Oleafly asks TeX Live which package owns the file, installs that package, and recompiles. You see the original error if the catalog is unavailable, the package belongs to a different TeX Live release, or the installation still fails.

If you try to change a system installation without permission, Oleafly can install into your personal TeX tree instead. The package row identifies where it ended up. Removing an owner package also removes the other files it provides, so read the **Included in** note before removing it.

## Which engine compiled my PDF?

- The toolbar shows the compiler saved for the current project.
- Tectonic builds use the bundled engine.
- pdfLaTeX, XeLaTeX, and LuaLaTeX builds use `latexmk` and the selected TeX distribution.
- Preflight's tagged export uses LuaLaTeX and writes to the normal build location.

## Templates and packages

Templates declare the packages they need, and Tectonic fetches them on first compile. Templates with on-demand fonts handle those separately. See [Templates](/docs/templates/#on-demand-fonts-the-setup-badge).
