# Document settings

Change paper size, margins, font, language, line spacing, and numbering in a dialog that edits the LaTeX preamble, the Typst set rules, or the Markdown front matter.

Each language keeps its page setup somewhere different: class options and preamble commands in LaTeX, `#set` rules in Typst, front matter in Markdown. **Document settings** gives you one form for all of them. When you apply it, Oleafly writes the change into your main file as ordinary source that you can read and edit later.

Open it with the **Document settings** button at the right end of the editor toolbar, or run **Document settings** from the ⌘K palette. The dialog always edits the project's main document, whichever file you have open.

## The fields

The form has four sections. The fields depend on the engine:

| Section | LaTeX | Typst | Markdown |
| --- | --- | --- | --- |
| Page | Page size, Columns, Margins | Page size, Margins, Columns | Document class, Page size, Columns, Margins |
| Text | Body font, Font size, Language | Body font, Font size, Language, Region | Body font, Font size, Language |
| Paragraph | Line spacing | Justification, Line spacing | Line spacing |
| Numbering | Numbered levels, Equation numbering | Heading numbering, Equation numbering | Section numbers |

Lists start with **Default**, which removes the setting so the class, template, or engine default applies again. Leave a text field empty for the same effect. Lengths take units, such as `2.5cm`, `1in`, or `11pt`, and Typst margins also accept `auto`. A value Oleafly can't use gets a short note under the field, and **Apply** waits until you fix it.

**Body font** suggests fonts as you type. In Typst projects, the list holds every font Typst can find and says where each comes from: the project's `fonts` folder, the computer, or Typst's built-in set. In LaTeX and Markdown projects, it lists fonts installed on the computer.

Choose **Apply** to write the changes, or **Cancel** to leave the file alone. When the main file is open in the editor, one ⌘Z undoes the whole change.

## Where the values go

### LaTeX

- **Page size**, **Columns**, and **Font size** become options of `\documentclass`.
- **Margins** go to the geometry package. Oleafly edits an existing `\geometry{…}` or geometry option, or adds `\usepackage[margin=…]{geometry}`.
- **Body font** writes `\setmainfont{…}` and loads fontspec. It needs the XeLaTeX or LuaLaTeX compiler, and the field says so until you pick one in the compile menu.
- **Language** adds the language to babel, uses `\setdefaultlanguage` when the document loads polyglossia, or adds `\usepackage[language]{babel}`. Use babel names such as `english`.
- **Line spacing** is **Single**, **One and a half**, **Double**, or a number such as `1.5`. It uses the setspace package, or `\linespread` when that is what the document already has.
- **Numbered levels** sets `secnumdepth`. Choose **None**, **Chapters only**, or how deep numbering goes, from **Down to sections** to **Down to subparagraphs**.
- **Equation numbering** writes `\numberwithin{equation}{…}` for **By section**, **By chapter**, or **By subsection**.

### Typst

Values go into the main file's `#set` rules. When a rule is missing, Oleafly adds it near the top:

- `#set page(paper: …, margin: …, columns: …)`
- `#set text(font: …, size: …, lang: …, region: …)`
- `#set par(justify: …, leading: …)`, where **Justification** is **Justified** or **Ragged right**
- `#set heading(numbering: …)`, with patterns such as `1.`, `1.1`, `1.a`, `I.`, or `A.`
- `#set math.equation(numbering: …)`, with `(1)`, `(1.1)`, or `1`

**Language** takes a two or three letter code such as `en`, and **Region** a two letter code such as `GB`.

Typst projects also get a **Build variants** section. Each variant is a named set of values that the document reads with `sys.inputs`, such as a draft and a camera-ready build. Use **Add variant**, give it a name, then add each value with **Add value**. Pick the variant to build from **Variant (this project)** in the compile menu.

### Markdown

Values go into the YAML front matter that Pandoc reads when it builds the PDF: `documentclass`, `papersize`, `classoption` for columns, `geometry` for margins, `mainfont`, `fontsize`, `lang`, `linestretch`, and `numbersections`. **Document class** offers `article`, `report`, `book`, `scrartcl`, `scrreprt`, and `memoir`. **Language** takes a tag such as `en-US`.

If the file has no front matter yet, the dialog says so, and **Apply** adds a block at the top. Front matter without a closing `---` line has to be fixed by hand first.

## Read-only fields

Some values belong to something else, and the dialog shows them greyed out with the reason underneath:

- **Set by the … class**: classes such as `acmart`, `IEEEtran`, `llncs`, and `beamer` fix their own margins, and some also fix the page size, font size, columns, line spacing, or language. A note at the top of the dialog names the class.
- **Set by the … style**: conference style packages such as those for NeurIPS, ICML, ICLR, CVPR, and ACL set the page size and margins. A note at the top of the dialog says which style is in charge.
- **The source sets each margin separately**: the document gives left, right, top, and bottom margins on their own instead of one `margin` value.
- **Set inside a conditional block**: the value sits inside `\if…` code, so changing it here could break the logic.
- **Set by the template**: in Typst, the `#set` rule holding the value has an `if` condition or passes `..` arguments, the way template code often does, so the dialog leaves it alone.
- **Set by an expression in the source**: the value is computed, not written out, so edit the source instead.

When a Typst document applies a template, a note at the top says that values set inside the template aren't shown, and that a value you set here overrides the template. In LaTeX, a similar note appears when part of the preamble lives in other files.

## Related pages

- [Packages](/docs/packages/): add other LaTeX or Typst packages
- [Compiling](/docs/compiling/): pick XeLaTeX or LuaLaTeX, and choose a Typst build variant
- [Document insights](/docs/document-insights/): see what the document contains
