An open API service indexing awesome lists of open source software.

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.

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.