https://github.com/marcusfrdk/docmath
Code to embed in your documentation to make LaTeX math interactive.
https://github.com/marcusfrdk/docmath
Last synced: 6 months ago
JSON representation
Code to embed in your documentation to make LaTeX math interactive.
- Host: GitHub
- URL: https://github.com/marcusfrdk/docmath
- Owner: marcusfrdk
- Created: 2024-04-23T14:14:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T15:11:24.000Z (about 2 years ago)
- Last Synced: 2024-04-24T17:34:14.314Z (about 2 years ago)
- Language: JavaScript
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DocMath
Code to embed in your documentation to make LaTeX math interactive.
## Installation
Include the following code in the head of your document:
### ``
```html
```
### ``
```html
// KaTeX
// - {{output}} is the output of the compute() function.
// - {{...key}} is each key in the initialize() object, such as {{a}} and {{b}} in this example.
template = "{{output}} = {{a}} + {{b}}";
// The function to compute {{output}}.
// ({a, b, ...}: Record<string, number>) => number
function compute({a, b, ...}){
return a + b;
}
// Initialize the input fields and values
//
// initialize(values, options?);
//
// values: {
// [id]: {
// value: number, // optional
// step: number | string, // optional
// min: number | string, // optional
// max: number | string, // optional
// }
// }
//
// options: {
// fractions: number,
// }
//
initialize({
a: {
value: 1,
step: 0.1,
min: 0,
max: "b", // The value of "b" (synced with the value of "b)
},
b: {
value: 10
},
...
});
```
## Template
The template used to render the interactive math is a string that containes the KaTeX math and the variables to be replaced.
KaTeX is a faster version of LaTeX that is used to render the math. You can find a list of supported functions [here](https://katex.org/docs/supported.html).
You can use any variable names in the template that are defined in the `initialize()` function. The `{{output}}` variable is the result of the `compute()` function.