Bring some unto your document!
1. Requirements ๐
In order to use LaTeX processing, you need to have a distribution installed. We recommend the TeX Live distribution. You'll also need to install the latex2svg python script provided with NML. You'll have to follow the installation instructions from the original latex2svg repository. If you don't want to add the script to your $PATH, you can set the executable path in the ยง{tex_env}[caption=LaTeX environment].
2. Inline Math ๐
You can add inline math by enclosing between two $:
$\lim_{n \to \infty} \Big(1 + \frac{1}{n}\Big)^n = e$โ$\pi = \sqrt{\sum_{n=1}^\infty \frac{1}{n^2}}$โ
You can make the non inline by specifying kind=block in it's property: $[kind=block] 1+1=2$ โ
(notice how it's not inside a paragraph)
3. Non Math LaTeX ๐
You can write outside of 's math environment, by enclosing your code between $|...|$:
$|\begin{tikzpicture} |
\begin{axis} |
\addplot3[patch,patch refines=3, |
shader=faceted interp, |
patch type=biquadratic] |
table[z expr=x^2-y^2] |
{ |
x y |
-2 -2 |
2 -2 |
2 2 |
-2 2 |
0 -2 |
2 0 |
0 2 |
-2 0 |
0 0 |
}; |
\end{axis} |
\end{tikzpicture}|$ |
Gives the following:
4. LaTeX environment ๐
You can define multiple environment, the default being main
@tex.env.fontsizeThe fontsize (in pt) specified to latex2svg (default: 12).@tex.env.preambleThe preamble prepended to every code.@tex.env.block_prependText to prepend to every non math code.@tex.env.execThe latex2svg executable path, defaults to latex2svg (need to be in your $PATH)
Replace env with the name of the custom environment you wish to define.
Here's a preamble to render gray:
@tex.main.fontsize = 9 |
@tex.main.preamble = \usepackage{xcolor} \\ |
\usepgfplotslibrary{patchplots} \\ |
\definecolor{__color1}{HTML}{d5d5d5} \\ |
\everymath{\color{__color1}} |
@tex.main.block_prepend = \color{__color1} |
To set the environment you wish to use for a particular element, set the env property:
5. Properties ๐
envThe environment to use, defaults to main.kindThe display kind of the rendered element:- inline (default for math mode) displays as part of the current paragraph.
- block (default for non math mode) display on it's own line.
captionCaption for accessibility, defaults to none.
6. LaTeX cache ๐
elements that have been successfully rendered to svg are stored in the cache database, to avoid processing them a second time. Note that this cache is shared between documents, so you don't need to reprocess them if they share the same environment. They are stored under the table named cached_tex, if you modify the env all elements will be reprocessed which may take a while...
7. Bindings ๐
nml.tex.push_math(kind, tex [, env [, caption]])inserts a math mode element.
nml.tex.push(kind, tex [, env [, caption]])inserts a non-math element.