hexo-filter-tikzjax
v1.0.2
Published
Server side PGF/TikZ renderer plugin for Hexo.
Downloads
68
Readme
hexo-filter-tikzjax
Server side PGF/TikZ renderer plugin for Hexo.
Render graphs, figures, circuits, chemical diagrams, commutative diagrams, and more in your blog posts.
No client side JavaScript required. Woo-hoo! 🎉
Installation
npm install hexo-filter-tikzjax
For the first run after installation, you need to run hexo clean
to clean the cache.
Configuration
Configure this plugin in your site's _config.yml
. Default values:
tikzjax:
# Enable TikZ rendering for all posts and pages.
# Or you can enable it per post by adding `tikzjax: true` to the front-matter.
every_page: false
# Add CSS to pages which contain TikZ graphs.
append_css: true
# URL of the font CSS file.
font_css_url: 'https://cdn.jsdelivr.net/npm/node-tikzjax@latest/css/fonts.css'
# Additional options that will be passed to node-tikzjax.
# See: https://github.com/prinsss/node-tikzjax/#usage
# tikzjax_options:
# showConsole: false
Usage
Add tikzjax: true
to the front-matter of posts/pages that you would like to enable TikZ rendering.
Wrap you TikZ code in a Markdown code block with language tikz
, and you are good to go!
```tikz
\begin{document}
\begin{tikzpicture}
% Your code here...
\end{tikzpicture}
\end{document}
```
TikZ code are rendered as static SVG images during the Hexo generation process. The SVG images are then embedded into the HTML pages so there is no client side JavaScript involved. The images will be updated automatically when you change the code.
For a full list of supported TikZ features and $\LaTeX$ packages, please refer to the node-tikzjax documentation.
[!TIP] Run
hexo generate
orhexo server
with--debug
option to see the debug messages, including the console output of the TeX engine. To clear the internal SVG cache, runrm -rf node_modules/hexo-filter-tikzjax/.cache
.
Example
As this plugin is greatly inspired by obsidian-tikzjax, you can expect the same syntax, features and rendering results.
---
title: 'Lorem Ipsum'
date: '2024/01/01 11:45:14'
mathjax: true
tikzjax: true
---
We love using $\LaTeX$ and Ti*k*Z in [Hexo](http://hexo.io)!
```tikz
\begin{document}
\begin{tikzpicture}[domain=0:4,scale=1.1]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot (\x,\x) node[right] {$f(x) =x$};
\draw[color=blue] plot (\x,{sin(\x r)}) node[right] {$f(x) = \sin x$};
\draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}
\end{document}
```
The above code will be rendered and embedded as an inline SVG image.
For more examples, please refer to the node-tikzjax.