TikZ figure in Moodle
School platforms do not display TikZ code, and many refuse pasted SVG. Compile the figure here, download it as PNG (or SVG if the platform accepts it), then insert it with the editor's “Image” button, like a photo.
Preamble (optional)
Your commands and TikZ libraries. Already loaded: tikz, amsmath, amssymb; pgfplots, tkz-tab and tikz-cd are added automatically when used, as are Otoolia's shortcuts (\R, \conj{A}, \proba…).
Preview
The preview will appear here.
Fix a figure you already published
Paste the whole content of the “Custom HTML” block here (the TikZ code is kept as a comment at the start of the block):
Using the figure in WordPress
- Paste the HTML block (recommended): add a “Custom HTML” block and paste the copied block. No image to upload, no plugin. The TikZ code is kept in the block as a comment, invisible to visitors: to fix a typo, paste the block back into “Fix a figure you already published”. You need an administrator account (WordPress strips SVG code pasted by other roles).
- Upload the .svg file: WordPress refuses SVG by default; install the “Safe SVG” plugin, then insert the file with an “Image” block.
The figure adapts to the screen width, stays crisp at any zoom, and several figures can share a page. It also works on any website or in an HTML file.
Frequently asked questions
Is my code sent to a server?
No. The TeX engine (TikZJax, TeX compiled to WebAssembly) runs in your browser. It weighs about 7 MB, downloaded once on the first generation; your browser keeps it afterwards.
Which packages can I use?
TikZ and all its libraries (\usetikzlibrary{…} in the preamble), pgfplots, tkz-tab, tikz-cd, tikz-3dplot, amsmath, amssymb, array.
For other packages (circuitikz, chemfig, tkz-euclide, venndiagram…), the Compile with the full engine button uses the TeX Live 2026 of Otoolia's LaTeX editor, still in your browser: you get a vector PDF and PNG images (no SVG).
Why is the SVG 40 to 80 KB?
The LaTeX fonts used by the figure are embedded in the file, so it displays identically everywhere without loading anything else. Once compressed by the web server, it is about half that size.
The figure does not compile: what now?
The tool points out the most common mistakes (unclosed braces or parentheses, missing semicolon, environment not closed). Custom commands must be defined in the preamble. To build a complex figure, Otoolia's LaTeX assistant generates trees, variation tables and plots without errors.
Engine: TikZJax (David Grice, after Jim Fowler), GPL-3.0 licence; tkz-tab package by Alain Matthes.
How to do it
- Paste the TikZ code (or a formula, in “Formula only” mode).
- Generate, then download the PNG ×2 with “White background”.
- In Moodle, click the editor's Image button and choose the file.
- Fill in the image description for students who use a screen reader.
Tips
- PNG is accepted everywhere; SVG stays sharper if your platform accepts it.
- For a Moodle quiz, one image per question: paste all the figures together and download the .zip.
- Moodle can also display formulas with its MathJax filter: keep images for figures.
Frequently asked questions
Why doesn't my SVG show on the platform?
Some platforms refuse or strip SVG for security reasons: use PNG, accepted everywhere.
What image size?
PNG ×2 is enough for screens; ×4 if the page will be printed.
Is my code sent to a server?
No: the TeX engine (TikZJax, in WebAssembly) runs in your browser; it is downloaded once (about 7 MB) and then kept.