# LaTeX maths to image

Draw a LaTeX maths formula as a sharp SVG or PNG picture, with a choice of font, size and colours.

Lays out a formula written in LaTeX maths notation and saves it as a picture that fits it exactly. It supports a fixed set of maths commands rather than a full TeX system, so nothing in a formula can read a file or run a program.

- Endpoint: `POST https://setget.net/v1/tools/math` with JSON `{"input": {...}}` (add `"wait": 30` to hold the reply until the job finishes)
- MCP: `run_tool` with `slug` = `math`
- Page: https://setget.net/tools/math

## Files in, files out

This is a file tool. Its file inputs take file references, not file contents and not web addresses.

- Get a reference by uploading: `curl -T FILE https://setget.net/drop/` prints a line `ref  <id>/f1`. Or `POST https://setget.net/v1/drops` with `{"files":[{"name","size"}]}`, PUT the bytes to the returned `upload.url` with the listed headers, and use the file's `ref`. Over MCP use the `drop` tool. A file under about 700 KB can also be sent in place as a `data:<type>;base64,<content>` URI.
- Uploads are at most 100 MB per file, are readable by anyone with the link, and expire (one hour by default). Programs are refused.
- The tool runs as a job. The reply is `{"tool", "ms", "result", "files", "job"}`: `result` is JSON, and every result file comes back in `files` as `{"name", "size", "content_type", "kind", "url", "ref"}`. Download it from `url`, or pass `ref` as the input of another file tool.
- A job still running when the wait ends answers 202 with `job`. Follow it with `GET https://setget.net/v1/jobs/<id>?wait=30`, or stream progress from `GET https://setget.net/v1/jobs/<id>/events` (over MCP: the `job` tool). A person can watch it at `job.url`.

## Inputs

- `latex` (required, string): The formula in LaTeX maths notation, with or without $ around it.
- `format` (optional, string, one of `svg`, `png`, default `"svg"`): svg stays sharp at any size; png is a fixed-size picture.
- `font_size` (optional, integer, default `24`, range 6..200): Size of the letters in points.
- `colour` (optional, string, default `"#000000"`): Colour of the formula: hex such as #1e3a8a, or a basic colour name.
- `background` (optional, string, default `"transparent"`): Background colour: hex such as #ffffff, a basic colour name, or "transparent".
- `font` (optional, string, one of `cm`, `stix`, `stixsans`, `dejavusans`, `dejavuserif`, default `"cm"`): Typeface: cm is the classic LaTeX look, stix resembles Times, stixsans and dejavusans are sans-serif, dejavuserif is a wider serif.
- `dpi` (optional, integer, default `200`, range 50..600): Resolution of a PNG, in dots per inch: 72 gives one pixel per point. Ignored for SVG.
- `padding` (optional, integer, default `6`, range 0..100): Empty space around the formula, in points.

## Example 1: The quadratic formula as SVG

```json
{"input":{"latex":"x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}"},"wait":30}
```

## Example 2: A dark blue PNG on white

```json
{"input":{"latex":"$e^{i\\pi} + 1 = 0$","format":"png","font":"stix","font_size":32,"colour":"#1e3a8a","background":"#ffffff","dpi":150},"wait":30}
```

## Example 3: A sum in a sans-serif font

```json
{"input":{"latex":"\\sum_{n=1}^{\\infty} \\frac{1}{n^2} = \\frac{\\pi^2}{6}","font":"dejavusans"},"wait":30}
```

**Is this full LaTeX?** No. It draws the maths that fits on one line: fractions, roots, powers and indices, sums, integrals, Greek letters, brackets that grow with \left and \right, accents, \text{} and the maths fonts. Environments such as matrix, align and cases, line breaks, colour commands and macros are not supported.

**Do I need to put $ around the formula?** No. Surrounding $, $$, \[ \] or \( \) are removed if you include them. \displaystyle and \textstyle are left out as well; the result lists them when that happens.

**Will the SVG look the same everywhere?** Yes. Every letter is stored as a shape, so no font needs to be installed where the picture is shown, and the file refers to nothing outside itself.

**Which characters can I use?** Latin letters with accents, Greek, Cyrillic and the usual maths symbols. Chinese, Japanese, Korean and emoji cannot be drawn: the tool says which character is the problem.

**How large is the picture?** It fits the formula plus the padding. For a PNG, raise the dpi for more pixels: the limit is 8,000 pixels per side.
