Render interactive JSXGraph boards in Quarto documents and export static SVG for PDF/Word outputs.
- Interactive JSXGraph boards for
htmlandrevealjs. - Static SVG export for
pdfanddocx. - Full control over
<iframe>layout, style, and source code display. - Works globally or per page in your Quarto project.
From GitHub
cd myProject
quarto add jsxgraph/jsxgraph-quartoManually
- Create
_extensions/jsxgraphin your project folder. - Copy
_extension.ymland folderluaandresourcesinto_extensions/jsxgraph.
To export JSXGraph boards as SVG (for HTML, PDF, or Word outputs), the following prerequisites and setup steps are required:
Make sure Node.js is installed on your system. This is required to run the npm packages needed for SVG export.
JSXGraph Extention supports different DOM generators to render SVGs. You can choose from chrome, jsdom, or playwright. The table below shows the required npm packages and setup for each option:
| Generator | npm / Setup Steps | Notes |
|---|---|---|
chrome |
Install via npm: bash npm install puppeteer Requires local Chrome installation. |
Download Chrome from Google Chrome. Uses real browser environment. |
playwright |
Install via npm: bash npm install playwright Then install Chrome for Playwright: bash npx playwright install chrome |
Provides a controlled browser environment. |
Note
These steps are only required for SVG export. For interactive HTML or revealjs outputs, no additional installation is needed.
Globally (_quarto.yml)
project:
type: website
filters:
- jsxgraph
format:
htmlPer page
---
title: "JSXGraph Test"
filters:
- jsxgraph
---| Attribute | Description | Default |
|---|---|---|
aspect_ratio |
Sets the width-to-height ratio. |
1/1 |
class |
Adds a CSS class to the <iframe>. |
none |
dom |
DOM generator for svg: chrome orplaywright. |
chrome |
echo |
Displays the JSXGraph source code. | false |
height |
Height in pixels (e.g. 500). |
— |
iframe_id |
Adds id="frame_id" to the <iframe> containing the JSXGraph illustration. |
— |
out |
Static export with svg; interactive html export with js. |
js |
reload |
Shows a reload button. | false |
src_css |
Path to jsxgraph.css. |
— |
src_jxg |
Path to jsxgraphcore.js. |
— |
src_mjx |
Path to the MathJax file. | — |
style |
Custom CSS (e.g. border: 5px solid red; border-radius: 10px;). |
none |
textwidth |
Absolute textwidth (e.g. 15.5cm, 5in). |
20cm |
unit |
Unit for widthand height (e.g. px, em, rem, cm, mm, in, pt). |
px |
width |
Width in pixels (e.g. 500). |
— |
```{.jsxgraph width="400" style="border:1px solid #ccc; border-radius:5px" echo=true}
var board = JXG.JSXGraph.initBoard('BOARDID', {
boundingbox: [-5, 5, 5, -5],
axis: true,
keepAspectRatio: true
});
var f = board.create('functiongraph', ['x^2']);
```
Check out a working example: example.qmd.
- SVG export works for
pdfanddocx. - Interactive export works for
htmlandrevealjs. - Use
echo=trueto display the JSXGraph source code below the board. - Customize layout via
width,height,style, andclass.
MIT License. See LICENSE for details.