> ## Documentation Index
> Fetch the complete documentation index at: https://help.milton.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Write LaTeX and see the PDF

Milton compiles LaTeX on your device. Your manuscript never goes to a server to be compiled.

## Compile

1. Open a `.tex` file in your project's files. (No file yet? Click **New file** → `.tex`, or [start from a template](https://help.milton.so/writing/templates.md).)
2. Press **Mod + S** (⌘S or Ctrl+S), or click **Recompile**.
3. The PDF appears on the right.

![A .tex file on the left and its compiled PDF on the right, with the Recompile button](https://mintcdn.com/milton-help/CQbZfUaauwZBJQyI/images/latex-editor-and-pdf.png?fit=max\&auto=format\&n=CQbZfUaauwZBJQyI\&q=85\&s=68904bea87f527dec54ed0c92572eb6d)

The first time, Milton downloads the LaTeX packages your document needs. After that, compiling works offline.

### Compile as you type

Click the chevron next to **Recompile** (**Compile options**) and turn on **Auto-compile**. Milton then shows a quick preview a couple of seconds after you stop typing. Citations may show as ?? in the preview until you compile fully.

![Compile options next to Recompile, with the Auto-compile switch](https://mintcdn.com/milton-help/CQbZfUaauwZBJQyI/images/latex-compile-options.png?fit=max\&auto=format\&n=CQbZfUaauwZBJQyI\&q=85\&s=e02a681681d1913b564c5ad1b7975e71)

### Download the PDF

Click the download icon in the PDF bar (**Download PDF**). To prepare a submission, see [Export for submission](https://help.milton.so/writing/export-and-submit.md).

## Several main files

If more than one file starts with `\documentclass`, Milton asks you to **Choose the main file**.

## Errors

When a compile fails, Milton keeps showing the last good PDF and lists the problems under the editor. Click an error to jump to its line.

With a subscription (or a [local agent](https://help.milton.so/ai/local-agents.md)), click **Fix with agent** to have the agent propose a fix.

![A failed compile: the error listed under the editor with Fix with agent, and the last good PDF still shown](https://mintcdn.com/milton-help/CQbZfUaauwZBJQyI/images/latex-compile-error.png?fit=max\&auto=format\&n=CQbZfUaauwZBJQyI\&q=85\&s=5d5ee38343215fb34afdee82bfcfa1d0)

Common messages:

* **"This document needs a LaTeX package that hasn't been downloaded yet"**: connect to the internet once and recompile.
* **"This document asks for biber, which Milton doesn't include."**: use `backend=bibtex` in `\usepackage[...]{biblatex}`.
* **"Compilation took longer than 2 minutes and was stopped."**: look for a loop or a very large figure.

## Jump between source and PDF

Use the arrows on the divider between the editor and the PDF: **Show this line in the PDF** (**Mod + Shift + J**) and **Show this place in the source**.

![The arrows on the divider between the editor and the PDF](https://mintcdn.com/milton-help/CQbZfUaauwZBJQyI/images/latex-source-pdf-arrows.png?fit=max\&auto=format\&n=CQbZfUaauwZBJQyI\&q=85\&s=b6cb82199d82c37a1c4d96d3ad5cc4a0)

## Editor tips

* **Mod + /** comments or uncomments a line.
* The **⋯** menu (**Editor options**) has **Wrap lines**, **Export…** and **Apply changes automatically**.
* **Insert figure…** in the **Editor options** (**⋯**) menu above the editor adds a figure. See [Add figures](https://help.milton.so/writing/figures.md).

The editor and compiling are free on every plan.

> [!NOTE]
>
> The first download of packages goes to the public TeX package host, which sees the package names and your IP address, never your text.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.