# `Ratex`
[🔗](https://github.com/akoutmos/ratex/blob/master/lib/ratex.ex#L1)

This library provides an Elixir wrapper around the Rust
[RaTeX](https://github.com/erweixin/RaTeX) library. This allows you
render SVGs and PNGs of mathematical expressions right in Elixir.

# `png_opts`

```elixir
@type png_opts() ::
  {:font_size, float()}
  | {:pixel_ratio, float()}
  | {:color, binary()}
  | {:inline, boolean()}
  | {:unicode_font_path, binary()}
```

# `svg_opts`

```elixir
@type svg_opts() ::
  {:font_size, float()}
  | {:color, binary()}
  | {:inline, boolean()}
  | {:unicode_font_path, binary()}
```

# `render_png`

```elixir
@spec render_png(expression :: String.t(), opts :: png_opts()) ::
  {:ok, binary()} | {:error, term()}
```

Generate a PNG binary from a given LaTeX math expression.

## Options

  * `:font_size` (`t:float/0`) - The base font size in pixels. The default value is `32.0`.

* `:pixel_ratio` (`t:float/0`) - The device pixel ratio for retina rasters. The default value is `2.0`.

* `:color` (`t:String.t/0`) - The color of the glpyhs as hexadecimal (e.g. `#112233`). The default value is `"#000000"`.

* `:inline` (`t:boolean/0`) - Render the expression as inline text as opposed to display. The default value is `false`.

* `:unicode_font_path` (`t:String.t/0`) - The absolute path to a TTF font file for non-ASCII text that may be used inside of an `\\text{...}` expression. If a font path is not provided the underlying RaTeX Rust library will attempt to use the platform fallback.

# `render_png!`

```elixir
@spec render_png!(expression :: String.t(), opts :: png_opts()) :: binary()
```

Same as `render_png/2` but raises on error.

# `render_svg`

```elixir
@spec render_svg(expression :: String.t(), opts :: svg_opts()) ::
  {:ok, binary()} | {:error, term()}
```

Generate an SVG from a given LaTeX math expression.

## Options

  * `:font_size` (`t:float/0`) - The base font size in pixels. The default value is `32.0`.

* `:color` (`t:String.t/0`) - The color of the glpyhs as hexadecimal (e.g. `#112233`). The default value is `"#000000"`.

* `:inline` (`t:boolean/0`) - Render the expression as inline text as opposed to display. The default value is `false`.

* `:unicode_font_path` (`t:String.t/0`) - The absolute path to a TTF font file for non-ASCII text that may be used inside of an `\\text{...}` expression. If a font path is not provided the underlying RaTeX Rust library will attempt to use the platform fallback.

# `render_svg!`

```elixir
@spec render_svg!(expression :: String.t(), opts :: svg_opts()) :: binary()
```

Same as `render_svg/2` but raises on error.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
