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].
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)
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:
You can define multiple environment, the default being main
@tex.env.fontsize
The fontsize (in pt) specified to latex2svg (default: 12).@tex.env.preamble
The preamble prepended to every code.@tex.env.block_prepend
Text to prepend to every non math code.@tex.env.exec
The 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:
env
The environment to use, defaults to main.kind
The display kind of the rendered element:caption
Caption for accessibility, defaults to none. 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...
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.