https://github.com/superle3/snippet-leaf
Overleaf port of obsidian-latex-suite. Make typesetting LaTeX as fast as handwriting through snippets, text expansion, and editor enhancements
https://github.com/superle3/snippet-leaf
latex math overleaf overleaf-extension snippets text-expansion
Last synced: 2 months ago
JSON representation
Overleaf port of obsidian-latex-suite. Make typesetting LaTeX as fast as handwriting through snippets, text expansion, and editor enhancements
- Host: GitHub
- URL: https://github.com/superle3/snippet-leaf
- Owner: superle3
- License: mit
- Created: 2025-07-13T15:36:36.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2026-04-16T15:23:47.000Z (2 months ago)
- Last Synced: 2026-04-16T21:35:26.770Z (2 months ago)
- Topics: latex, math, overleaf, overleaf-extension, snippets, text-expansion
- Language: TypeScript
- Homepage:
- Size: 21.9 MB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Snippetleaf
A port of [Obsidian Latex Suite](https://github.com/artisticat1/obsidian-latex-suite) to overleaf that aims to make typesetting LaTeX math as fast as handwriting.
Inspired by [Gilles Castel's setup using UltiSnips](https://castel.dev/post/lecture-notes-1/).

The plugin's main feature is **snippets**, which help you write LaTeX quicker through shortcuts and text expansion! For example, type
- "sqx" instead of "\sqrt{x}"
- "a/b" instead of "\frac{a}{b}"
- "par x y " instead of "\frac{\partial x}{\partial y}"
See [Gilles Castel's writeup](https://castel.dev/post/lecture-notes-1/) for more information.
The plugin comes with a [set of default snippets](https://github.com/superle3/snippet-leaf/blob/main/src/default_snippets.js), loosely based on [Gilles Castel's](https://castel.dev/post/lecture-notes-1/#other-snippets). You can modify them, remove them, and write your own.
## Usage
To get started, type "dm" to enter display math mode. Try typing the following:
- "xsr" → "x^{2}".
- "x/y Tab" → "\\frac{x}{y}".
- "sin @t" → "\\sin \\theta".
**Have a look at the [cheatsheet](#cheatsheet)** for a list of commonly used default snippets.
Once these feel familiar, you can check out the [**default snippets**](https://github.com/artisticat1/obsidian-latex-suite/blob/main/src/default_snippets.js) for more commands. e.g.
- "par Tab f Tab x Tab" → "\\frac{\\partial f}{\\partial x}".
- "dint Tab 2pi Tab sin @t Tab @t Tab" → "\\int\_{0}^{2\pi} \\sin \\theta \\, d\\theta".
You can also add your own snippets! [For more info on writing snippets, see **here**](#snippets). You can [view snippets written by others and share your own snippets here](https://github.com/artisticat1/obsidian-latex-suite/discussions/50).
Aside from snippets, the plugin also comes with several other features that aim to make writing LaTeX easier.
## Installation
### Firefox
- Go the [latest release](https://github.com/superle3/snippet-leaf/releases/latest) and download the `.xpi` file in the firefox based browser you want to add the extension.
- There should open a popup, click on `Continue to Installation` and when its done downloading, click `add`.
- If for whatever reason this doesn't work or you can't download it on that browser, you first hide any sidebar on the left/right and drag-and-drop the `.xpi` file from your file-explorer in firefox. It should give you a popup where it asks you if the addons should be added. Click `add` to install the addon.
### Chromium (Chrome, Edge, Brave, Opera, Vivaldi, etc)
- Go to the [latest release](https://github.com/superle3/snippet-leaf/releases/latest) and download the `snippetleaf-.zip` file.
- Extract the zip file into any folder, for example `snippetleaf`.
- Inside the folder `snippetleaf`, there should be a file called `manifest.json`, if there is only a folder in `snippetleaf`, check if that folder has a file `manifest.json`.
- Go to `chrome://extensions` or open your extensions settings. (the url `chrome://extensions` might get redirected to `://extensions` like `brave://extensions`).
- turn on developer mode
- Click on `Load unpacked`
- Select the folder which contains the `manifest.json` file, in this example thus `snippetleaf`.
To check if the installation succeeded, reload your overleaf website and there should be little message in the corner saying `Snippetleaf settings updated!`.
> [!NOTE]
> For pictures of the installation on brave see https://github.com/superle3/snippet-leaf/discussions/23#discussioncomment-14723470.
> This addon relies on a very recent patch of overleaf which has not been brought into `overleaf-toolkit`. Thus if you self-host your overleaf instance and you can patch your instance, see https://github.com/superle3/snippet-leaf/discussions/23#discussioncomment-14732840 on how to patch your `overleaf-toolkit`.
### Safari/other browsers
Not supported, use a chromium/firefox browser. If anyone is willing to release this addon for safari you can open an issue and I'll redirect it to that version. As for other browsers, you can open up an issue asking for support if its not already supported.
### Chrome extension store/ Edge extension store/ Mozilla addons store
Coming soon(ish), need to make an icon and then I'll try to release it on there.
## Features
### Auto-fraction
Lets you type "1/x" instead of "\frac{1}{x}".
For example, it makes the following expansions:
- `x/` → `\frac{x}{}`
- `(a + b(c + d))/` → `\frac{a + b(c + d)}{}`
and moves the cursor inside the brackets.
Once done typing the denominator, press Tab to exit the fraction.

### Matrix shortcuts
While inside a matrix, array, align, or cases environment,
- Pressing Tab will insert the "&" symbol.
- Pressing Enter will insert "\\\\" and move to a new line.
- Pressing Shift + Enter will move to the end of the next line (which you can use to exit the matrix).

### Tabout
To make it easier to navigate and exit equations,
- Pressing Tab while the cursor is at the end of an equation will move the cursor outside the `$` symbols.
- Otherwise, pressing Tab will advance the cursor to the next closing bracket: `)`, `]`, `}`, `>`, or `|`.
### Visual snippets
Sometimes you want to annotate math, or cancel or cross out terms. Selecting some math with the cursor and typing
- "U" will surround it with "\\underbrace".
- "O" will surround it with "\\overbrace".
- "C" will surround it with "\\cancel".
- "K" will surround it with "\\cancelto".
- "B" will surround it with "\\underset".

### Auto-enlarge brackets
When a snippet containing "\\sum", "\\int" or "\\frac" is triggered, any enclosing brackets will automatically be enlarged with "\\left" and "\\right".

### Snippets
_Snippets_ are shortcuts that allow you to insert certain text based on certain triggers. For example, the default snippet
```typescript
{trigger: "@l", replacement: "\\lambda", options: "mA"}
```
will expand "@l" to "\lambda".
Snippets can be edited in the plugin settings. The structure of a snippet is as follows:
```typescript
{
trigger: string | RegExp,
replacement: string | (arg) => string | false,
options: string,
priority?: number,
description?: string,
flags?: string,
version?: 1 | 2,
}
```
- `trigger` : The text that triggers this snippet.
- Triggers can also be regular expressions. [See here for more info.](./DOCS.md#regex-snippets)
- `replacement` : The text to replace the `trigger` with.
- Replacements can also be JavaScript functions. [See here for more info.](./DOCS.md#function-snippets)
- `options` : See below.
- `priority` (optional): This snippet's priority. Snippets with higher priority are run first. Can be negative. Defaults to 0.
- `description` (optional): A description for this snippet.
- `flags` (optional): Flags for regex snippets.
- `version` (optional): version number for snippet syntax. [See here for more info](./DOCS.md#versions)
#### Options
- `t` : Text mode. Only run this snippet outside math
- `m` : Math mode. Only run this snippet inside math. Shorthand for both `M` and `n`
- `M` : Block math mode. Only run this snippet inside a `$$ ... $$` or `\[ ... \]` block
- `n` : Inline math mode. Only run this snippet inside a `$ ... $` or `\( ... \)` block
- `A` : Auto. Expand this snippet as soon as the trigger is typed. If omitted, the Tab key must be pressed to expand the snippet
- `r` : [Regex](./DOCS.md#regex-snippets). The `trigger` will be treated as a regular expression
- `v` : [Visual](./DOCS.md#visual-snippets). Only run this snippet on a selection. The trigger should be a single character
- `w` : Word boundary. Only run this snippet when the trigger is preceded (and followed by) a word delimiter, such as `.`, `,`, or `-`.
Insert **tabstops** for the cursor to jump to by writing "@0", "@1", etc. in the `replacement`.
For examples and more details on writing snippets, including **regex** snippets and **function** snippets, [have a look at the **documentation**](DOCS.md).
You can [view snippets written by others and share your own snippets here](https://github.com/artisticat1/obsidian-latex-suite/discussions/50).
> [!WARNING]
> Snippet files are interpreted as JavaScript and can execute arbitrary code.
> Always be careful with snippets shared from others to avoid running malicious code.
## Cheatsheet
| Trigger | Replacement |
| ----------------- | -------------- |
| mk | \\( \\) |
| dm | \\[
\\] |
| sr | ^{2} |
| cb | ^{3} |
| rd | ^{ } |
| \_ | \_{ } |
| sq | \\sqrt{ } |
| x/yTab | \\frac{x}{y} |
| // | \\frac{ }{ } |
| " | \\text{ } |
| text | \\text{ } |
| x1 | x\_{1} |
| x,. | \\mathbf{x} |
| x., | \\mathbf{x} |
| xdot | \\dot{x} |
| xhat | \\hat{x} |
| xbar | \\bar{x} |
| xvec | \\vec{x} |
| xtilde | \\tilde{x} |
| xund | \\underline{x} |
| ee | e^{ } |
| invs | ^{-1} |
When running a snippet that **moves the cursor inside brackets {}, press Tab to exit the brackets**.
### Greek letters
| Trigger | Replacement | Trigger | Replacement |
| ------- | ------------ | ------- | ----------- |
| ;a | \\alpha | eta | \\eta |
| ;b | \\beta | mu | \\mu |
| ;g | \\gamma | nu | \\nu |
| ;G | \\Gamma | xi | \\xi |
| ;d | \\delta | Xi | \\Xi |
| ;D | \\Delta | pi | \\pi |
| ;e | \\epsilon | Pi | \\Pi |
| :e | \\varepsilon | rho | \\rho |
| ;z | \\zeta | tau | \\tau |
| ;t | \\theta | phi | \\phi |
| ;T | \\Theta | Phi | \\Phi |
| ;k | \\kappa | chi | \\chi |
| ;l | \\lambda | psi | \\psi |
| ;L | \\Lambda | Psi | \\Psi |
| ;s | \\sigma | | |
| ;S | \\Sigma | | |
| ;o | \\omega | | |
| ome | \\omega | | |
For Greek letters with short names (2-3 characters), just type their name,
e.g. "pi" → "\\pi".
## Acknowledgements
- [@artisticat1](https://github.com/artisticat1)'s [Obsidian Latex Suite](https://github.com/artisticat1/obsidian-latex-suite) for the snippet engine.
- [@TeXlyre](https://github.com/TeXlyre/codemirror-lang-latex) for the LaTeX language support.
- [@tth05](https://github.com/tth05)'s [Obsidian Completr](https://github.com/tth05/obsidian-completr) for the basis of the tabstop code.
- [Dynamic Highlights](https://github.com/nothingislost/obsidian-dynamic-highlights/blob/master/src/settings/ui.ts) for reference.
- [Quick Latex for Obsidian](https://github.com/joeyuping/quick_latex_obsidian) for inspiration.
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
## Coming from Obsidian latex suite
See the [DOCS](./DOCS.md#tranvsering%20obsidian%20settings)
## Support
If you like this plugin and want to say thanks, you can buy the original author of obsidian latex suite coffee here.